Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp831914pxk; Sat, 12 Sep 2020 01:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl/PhKm2KACDAPaHk41jjiyfvQACum5XyWKwmp6ndFmvLyfXb5qwtGXx51X5a4ooGvE8RS X-Received: by 2002:a17:906:934e:: with SMTP id p14mr5242690ejw.348.1599899871451; Sat, 12 Sep 2020 01:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599899871; cv=none; d=google.com; s=arc-20160816; b=KNxHKZxlh0NBrzKXmnMnuZGPy7pnDl2BtoPCrgD/ad2k3uo2G6/7b2YDJhnFQ70QUK WtO/6HT9byQcTwDJK8hSS6qbtkYdTDrivreBoufF5jkJE0LxjGE+jsXGDLpLc5V33jkm NSM4Gu9JxcbI8cWVaVwjDSJumwfsieEGXtQfqfreZ8sO3aHsWNjiFP4wYPxjiD4Dv+U3 XhMIo9zKsyCPSkfyXbB2vpcKh9vBN8OgMDzzvuTNY45vBU0AOPrf4r/Q1PF26r1t/ZLT dhicgqsy21hfuq7dRdW0XmWXpspAcQ3yRSkdekMDyN6W+SCh12uG8Lla/GUnipY6a4XX ozeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HqETZNtM803hggZEKY0YTeUKzR9MbI+z8EnhB2YOdKs=; b=YiTS6mOJ8F1XP7xR1PEMGaZFrQMGvPkWRf/wT70eSc8EiU12WBlbjpyFwATaz8Wpdp qLMU/UqB+c2vtbGQZYa9XOxk4E4HxziUfefA34cPXxTw5AtuxoThMURW+wjemQyDZIQq EBH6xYJ58NPqDzLjiodo7r4ndosrwqWhotIa37TmaMGJI3IBxJWP0pkLqn0QLwnXTjcs eYHRMFl4CwAM/Y1TLYZkEza2GRWFb9xurP4IEaZZTI2zT1Plo+zm9U1fe+ArlWGmx0/T o46634M8vPXg6gZJDBxHo1+eTmGPbt9tB4dHghEZxKueGwwAAuB31PL2GXog5LHbIQgO XGrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si15si2971084ejb.246.2020.09.12.01.37.11; Sat, 12 Sep 2020 01:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILIg5 (ORCPT + 99 others); Sat, 12 Sep 2020 04:36:57 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:57326 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgILIg5 (ORCPT ); Sat, 12 Sep 2020 04:36:57 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 8C4D172CA54; Sat, 12 Sep 2020 11:36:52 +0300 (MSK) Received: from altlinux.org (sole.flsd.net [185.75.180.6]) by imap.altlinux.org (Postfix) with ESMTPSA id 40EEF4A4A16; Sat, 12 Sep 2020 11:36:52 +0300 (MSK) Date: Sat, 12 Sep 2020 11:36:52 +0300 From: Vitaly Chikunov To: Tianjia Zhang Cc: Herbert Xu , "David S. Miller" , David Howells , 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 , Gilad Ben-Yossef , Pascal van Leeuwen , 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, Xufeng Zhang , Jia Zhang Subject: Re: [PATCH v6 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm Message-ID: <20200912083652.dxosjsartbvnxq2r@altlinux.org> References: <20200903131242.128665-1-tianjia.zhang@linux.alibaba.com> <20200903131242.128665-9-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20200903131242.128665-9-tianjia.zhang@linux.alibaba.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Sep 03, 2020 at 09:12:42PM +0800, Tianjia Zhang wrote: > 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 (coding, not crypto It looks not breaking ecrdsa/streebog handling and accords to rfc draft: https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 5.1.4.2. Hash Functions The sm2 digital signature algorithm requires the hash functions approved by Chinese Commercial Cryptography Administration Office, such as sm3. Reviewed-by: Vitaly Chikunov Thanks, > --- > 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;