Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp533820ybg; Tue, 9 Jun 2020 06:51:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyjnpu9iWIkqCdYBeR37q93wriszjFkxJ7wcSytb/rWOVa8MF0dAfflRmfkDzRn+2qd5MY X-Received: by 2002:a17:906:fc20:: with SMTP id ov32mr24418506ejb.531.1591710675711; Tue, 09 Jun 2020 06:51:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591710675; cv=none; d=google.com; s=arc-20160816; b=A9CANJlQ7tadHbD9bOOQ39FqEkvPIjTXb2iEdITm1o2e/5h31S/Qj5M47fUzC4iwue 9wV8VCKlKKH4wXic4NNRBbSDHYg3wxi8sJw1EphekUPI6XZzYWDmX51BrjLGPG+YDgSb XRqMSyus2VBalQk5G5kx6QkRuxGZ4CoSfD8uzFHVAwTNpBPAZ+0mZNWJ5S7rIqzy8q2I GBzI8sUgHGjTEzlvqS/17Q2NrY8MJNHk3mMwb8Nk6ohIGvpz9GaUlPOpLbwPCuUL8aoe 2wFI5kCvJKMWs38RixM1xz0ykCNTuA4dbNb4pXn2dhiBUeudhA6ghxFGyKTX8xurfswu 6UuA== 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=gGE84LYPFUZwZW2i3z+PPvXUGA4Ff2M22XxR3O4oNWBrncRhDioxn51wjy8jvg/YEX n29YkQVsDxTNpSt593rxMLfV1Yv/JNl6SLoi3ioRfcamy/xdlicwX7qTKvveyaac5kXu 0eNBlfU3UuVaBYZ4UH+ZRRfzmKC6tMu8vS0mgEQWMJHr09JTIn8+gFhbvCcjvLc323df FwXLBQM0VLI8QXDi/zMfXDr8gSPRA1WumL3+yK0iC9yjpjblt9XjnirbTscclWtDGJPd 2v0ESddTeECDNaoXIzkCZo6mlgiX8ij9yMv7VfwBKt9qs42FshS1Fzg4TMAXDor8DzEZ 2KmQ== 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; 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 v10si11705653eda.476.2020.06.09.06.50.51; Tue, 09 Jun 2020 06:51:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730338AbgFINtu (ORCPT + 99 others); Tue, 9 Jun 2020 09:49:50 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:52082 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730218AbgFINtI (ORCPT ); Tue, 9 Jun 2020 09:49:08 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R911e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07425;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0U.4eknk_1591710542; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U.4eknk_1591710542) by smtp.aliyun-inc.com(127.0.0.1); Tue, 09 Jun 2020 21:49:02 +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, zhang.jia@linux.alibaba.com, tianjia.zhang@linux.alibaba.com Subject: [PATCH v3 8/8] integrity: Asymmetric digsig supports SM2-with-SM3 algorithm Date: Tue, 9 Jun 2020 21:48:55 +0800 Message-Id: <20200609134855.21431-9-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609134855.21431-1-tianjia.zhang@linux.alibaba.com> References: <20200609134855.21431-1-tianjia.zhang@linux.alibaba.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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