From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F32EAC433E2 for ; Sat, 12 Sep 2020 08:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAC60214F1 for ; Sat, 12 Sep 2020 08:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbgILIg5 (ORCPT ); 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; From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vitaly Chikunov Date: Sat, 12 Sep 2020 08:36:52 +0000 Subject: Re: [PATCH v6 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm Message-Id: <20200912083652.dxosjsartbvnxq2r@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit List-Id: References: <20200903131242.128665-1-tianjia.zhang@linux.alibaba.com> <20200903131242.128665-9-tianjia.zhang@linux.alibaba.com> In-Reply-To: <20200903131242.128665-9-tianjia.zhang@linux.alibaba.com> To: Tianjia Zhang Cc: Stephan Mueller , Brendan Higgins , Jia Zhang , Mimi Zohar , David Howells , keyrings@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Herbert Xu , Masahiro Yamada , James Morris , Lakshmi Ramasubramanian , Marcelo Henrique Cerri , Waiman Long , "Serge E. Hallyn" , Alexandre Torgue , "Steven Rostedt (VMware)" , Gilad Ben-Yossef , Tushar Sugandhi , linux-arm-kernel@lists.infradead.org, Pascal van Leeuwen , linux-kernel@vger.kernel.org, Xufeng Zhang , linux-security-module@vger.kernel.org, linux-crypto@vger.kernel.org, Maxime Coquelin , Johannes Weiner , Colin Ian King , Andrew Morton , "David S. Miller" 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; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 121D0C433E2 for ; Sat, 12 Sep 2020 08:38:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 90B5C214F1 for ; Sat, 12 Sep 2020 08:38:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r1aS7hYK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90B5C214F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zJy0UX/Tv/xcMMMaR1J5ezcVb3reb0H30QFBhI/K2Ro=; b=r1aS7hYKqAI2PEELInuBkYBNo wW1hL1ic8RgA3vYOKAIWK9MwL0+YYow9IcmxeiUYLYVWgXLtZtFVRfahxFuT9zhfQlGwmWcIzlXDw 8FJE0yudk0U4K0b1pz6g8RZVEf81UXDPOdcJ+PyJtDP3YoTXj0f/2jo3sR2DysbkDF+qQFBs78XHF 0caoM9O8TqS3XtpbVMkc+y5hK/b0LC9aB0wJLOjN3bWQwfO5KnX3C1KNy4TqmTsqTDI8PnV8F/bkN yC7SDcAfflbj1IuIvIyUKvrKdNgX0GgUhJ59VcK7iTg3uZt9mj9sXvG88sVZzk5Iy5du13ZgwEHyu j61gcpUoA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kH11n-0004Q4-Un; Sat, 12 Sep 2020 08:37:00 +0000 Received: from vmicros1.altlinux.org ([194.107.17.57]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kH11k-0004PZ-Ue for linux-arm-kernel@lists.infradead.org; Sat, 12 Sep 2020 08:36:58 +0000 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 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-Disposition: inline In-Reply-To: <20200903131242.128665-9-tianjia.zhang@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200912_043657_266735_A0D6B153 X-CRM114-Status: GOOD ( 15.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephan Mueller , Brendan Higgins , Jia Zhang , Mimi Zohar , David Howells , keyrings@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Herbert Xu , Masahiro Yamada , James Morris , Lakshmi Ramasubramanian , Marcelo Henrique Cerri , Waiman Long , "Serge E. Hallyn" , Alexandre Torgue , "Steven Rostedt \(VMware\)" , Gilad Ben-Yossef , Tushar Sugandhi , linux-arm-kernel@lists.infradead.org, Pascal van Leeuwen , linux-kernel@vger.kernel.org, Xufeng Zhang , linux-security-module@vger.kernel.org, linux-crypto@vger.kernel.org, Maxime Coquelin , Johannes Weiner , Colin Ian King , Andrew Morton , "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel