Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp357064ybt; Wed, 8 Jul 2020 01:30:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRdmmtZV+S9CYBVpjuR1cyAW6gina/NvPwMkpFq8yahIEm95bxavOGrmuBewuztBDloltZ X-Received: by 2002:a50:f702:: with SMTP id g2mr66472722edn.348.1594197002050; Wed, 08 Jul 2020 01:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594197002; cv=none; d=google.com; s=arc-20160816; b=CNt/KTCdaq2GMe9kUu0X0TeO9x9Xsz78IJi9RRy0lW0iPUQfvwGQ1obRPxOQqm6FSy JbN9SvNkMmx+OKk8xwNtku1dlasD0Rx2Jf7CUGxXCMwb65Hw2TI5IOCdWLeY/hO8LB3J VfoDV6NWi73oh2KSvNzVPsrqCk7arfy49626NtXtriwrTCWdX4YcOkbaDw0yPZZDmOIo HdN8Eb6tEtd+xNGu4Fd4+rAC63w4hc/A5K44CoV2DS+KqEGe4ml/0LaMafr6RPX8Na/k OF6H/Y3HyMIMXrAdrbBfC0MQObF7KlnfCqg0/RbMT17vd2fBLr+pXzdmnN8uxopyr5jF fhHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=DiBfpK5iegMidYVKMwv8riS1jgovaXC4qvtXvw1geXE=; b=E9JM2qJ4zDbZi1oYWpm/NqzG/97g2UV+f2JalNAyN65cZXoZfyUZVykWRyoGSyMD9C /w8utrpj1xhOPjO+7tpaN5AfeuXz2TZxiTbhleoGOdnAYB8Vv9IAOxDuVhuG8TuxnJhB 5OHpCGaxzZ29RzVvGPJgGMMVMcxLlfJVzTb3Rlcc1iIThNtjvQDezaiVVaENpg3IPJg1 KJaBUKMUhd/D9YDaOyEcN78tYqFWCSTtxhBIZHNRFuUNYyHWnFV+4pj96dB4YTGUYM9f gPqbmy3pQIGa7Q9MKNEsMybROmil9pXO0IpCGkTjZvRXDcrVHtlwbg2y+99ci4waHlOq f/1Q== 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 g4si16438052edq.459.2020.07.08.01.29.38; Wed, 08 Jul 2020 01:30:02 -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 S1728219AbgGHI2l (ORCPT + 99 others); Wed, 8 Jul 2020 04:28:41 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:55649 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbgGHI2d (ORCPT ); Wed, 8 Jul 2020 04:28:33 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0U26.E3t_1594196905; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U26.E3t_1594196905) by smtp.aliyun-inc.com(127.0.0.1); Wed, 08 Jul 2020 16:28:25 +0800 From: Tianjia Zhang To: herbert@gondor.apana.org.au, davem@davemloft.net, dhowells@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, jmorris@namei.org, serge@hallyn.com, nramas@linux.microsoft.com, tusharsu@linux.microsoft.com, zohar@linux.ibm.com, gilad@benyossef.com, pvanleeuwen@rambus.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, zhang.jia@linux.alibaba.com, tianjia.zhang@linux.alibaba.com Subject: [PATCH v4 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm Date: Wed, 8 Jul 2020 16:28:18 +0800 Message-Id: <20200708082818.5511-9-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200708082818.5511-1-tianjia.zhang@linux.alibaba.com> References: <20200708082818.5511-1-tianjia.zhang@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org 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 --- 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 4e0d6778277e..9350fcfb9bf2 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.17.1