Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2588072pxk; Sun, 20 Sep 2020 09:23:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNDkOH9jTW3PSaFjIXEa0nbFVWlTvnTLZmJTorRfOTJhiHSdlLrqrKujyo11Ojk3BSNx7S X-Received: by 2002:a05:6402:2c3:: with SMTP id b3mr48485306edx.213.1600618983944; Sun, 20 Sep 2020 09:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600618983; cv=none; d=google.com; s=arc-20160816; b=U+3bcbLlr5ArQ8p3pxFJFyPHMjv4+uPrE3Y/E1tgNZXv+oTa+MXXZvCSIFV07dzNdv DMxxqhJH5S4q2boqme6bvXeG0cIRPG5jerxUoJpTwssMI0GpVgKpeQRMr3OfGYw8d/Tg hL32zmfINsk0Gz3tHj5yqr3A4hriy8GqJeEYA7Jck3/wwWJKx8gaWgitdw3NQlwKkDSU bMzAvc1VZEAgSNjaObgMti/BA+SdYE+UTOi32KXsxeXy6AjGP2yGRdVR7016cKcgNsC/ WrESEV1iATu5RVpKoRvJGkw0d310MuNanOskmzh+DlzDBPXKcC3jsGo0Q0hgpCJRJV1j VcUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bqwmKDOtr7y4IPCLrToWJMJOjqKnJHq3Imsui38/JtU=; b=PBDxK43Ov1h6ocT/ndKE3T+s7NMy1HGqah11x9D4MswUxKAQZ3JdWBj8vR7rv0m2d1 7GB8GsYsBGlZaPXAMXVfKRlPBLeiqZULhljwV7K8+qQ6B7RNhN29HlYM+yp4akK5TD4U 80lPgtkvtRczo/o8x3O3orIVyVoIXr0Hl/jaWq5SQR3AfGEBMpyq2op2Bguq+bCL8K3+ Ozn9d7r1QhyXqzgmQjqZEfMGh2r3riVZiu1kwx70QbFVO1OFRlDPfAn0NC6+MjgLfxTl m7MVi0CigRTqgoE/1quD5iuCS8jLR8GoNV/77Kvt3+pDMezV7AzuBqovxVbos5n6Ud4/ 46Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si6455595eja.581.2020.09.20.09.22.40; Sun, 20 Sep 2020 09:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbgITQV3 (ORCPT + 99 others); Sun, 20 Sep 2020 12:21:29 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:50650 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbgITQVT (ORCPT ); Sun, 20 Sep 2020 12:21:19 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R591e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=34;SR=0;TI=SMTPD_---0U9VME3F_1600618869; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U9VME3F_1600618869) by smtp.aliyun-inc.com(127.0.0.1); Mon, 21 Sep 2020 00:21:10 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , David Howells , Eric Biggers , Jarkko Sakkinen , Maxime Coquelin , Alexandre Torgue , James Morris , "Serge E. Hallyn" , Stephan Mueller , Marcelo Henrique Cerri , "Steven Rostedt (VMware)" , Masahiro Yamada , Brendan Higgins , Andrew Morton , Johannes Weiner , Waiman Long , Mimi Zohar , Lakshmi Ramasubramanian , Colin Ian King , Tushar Sugandhi , Vitaly Chikunov , "Gilad Ben-Yossef" , Pascal van Leeuwen , linux-crypto@vger.kernel.org, keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Xufeng Zhang , Jia Zhang , Tianjia Zhang Subject: [PATCH v7 10/10] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm Date: Mon, 21 Sep 2020 00:21:03 +0800 Message-Id: <20200920162103.83197-11-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20200920162103.83197-1-tianjia.zhang@linux.alibaba.com> References: <20200920162103.83197-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang Tested-by: Xufeng Zhang Reviewed-by: Mimi Zohar Reviewed-by: Vitaly Chikunov --- security/integrity/digsig_asymmetric.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c index cfa4127d0518..b86a4a8f61ab 100644 --- a/security/integrity/digsig_asymmetric.c +++ b/security/integrity/digsig_asymmetric.c @@ -99,14 +99,22 @@ int asymmetric_verify(struct key *keyring, const char *sig, memset(&pks, 0, sizeof(pks)); pks.hash_algo = hash_algo_name[hdr->hash_algo]; - if (hdr->hash_algo == HASH_ALGO_STREEBOG_256 || - hdr->hash_algo == HASH_ALGO_STREEBOG_512) { + switch (hdr->hash_algo) { + case HASH_ALGO_STREEBOG_256: + case HASH_ALGO_STREEBOG_512: /* EC-RDSA and Streebog should go together. */ pks.pkey_algo = "ecrdsa"; pks.encoding = "raw"; - } else { + break; + case HASH_ALGO_SM3_256: + /* SM2 and SM3 should go together. */ + pks.pkey_algo = "sm2"; + pks.encoding = "raw"; + break; + default: pks.pkey_algo = "rsa"; pks.encoding = "pkcs1"; + break; } pks.digest = (u8 *)data; pks.digest_size = datalen; -- 2.19.1.3.ge56e4f7