Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4070184pxf; Tue, 23 Mar 2021 01:36:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCASMOFCwm4X6+8HN61P2X1dFkX3Ain5n12t0RHtErMPDk97nS/VJiMzkDucaE1pvx/5nW X-Received: by 2002:a05:6402:d4:: with SMTP id i20mr3509557edu.147.1616488598636; Tue, 23 Mar 2021 01:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616488598; cv=none; d=google.com; s=arc-20160816; b=zlQDlKpvyBzh4VqPOrgiNOQ+LedgBhmCxyDLL0GaAo3K24o1cmzTfsKchPWE1WFQgw p+AmZJ9nJsf7mhACfREOZHti3cdxke8G0LuSWnw8XxZ+0/Ufq26Frg6JVOEamGfs0+9x kaOH3MpzD6KsJ4pXGK669X96oZeH7zbX7mCnoZdbOLcpGzagX1v5DxbADLEW8GT69IWl ml2WP5O5g9e/TFSlUgE9bSGCbX3adtFmmWhU360kjZwpMMTvbOxfc8UNXSy9+VqRY3y4 St3Q956PFiJSaG4jse/PtrPOtdDLT1F5B33uN+6WUPnOAK3QWjAFQ6HyjoLPn/wUdDV3 wzJQ== 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 :message-id:date:subject:cc:to:from; bh=2OkiWcf53dwxP8oW6gVyzcIb8AZauqDaMZ2/u37cAeA=; b=G0fOocZJCjOyuytkc1Tc6C6rn6NTqWQGTqiCbpbDf+2+knRexVZo8h08YZAkn5N9iZ yvkDSfQESxVqOR9caKJeN1AQO716Tx1ka0+QSfRdaokLNHxHtApUiekWGLeLq4oHTNiD P1RVytKwFQLf/mo6RMz8NHpY3y7w5PVMrG+AqSdP5TbrB0furQq/0YWFK0XdjmDbuXcD d3rCjzmoeV3N9jXMYBm7GDzwl/ZoLzSzw9sQgCsSKQzpHGj0u+jcVQ9YWaDrbe84t50V leGbnr0OotrOuD9rIAJrGKSQZcvKEvm+yASntWLuPkxcpGm811ebIwaMhFz+mgo078oh QnKw== 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 mj11si3980896ejb.589.2021.03.23.01.36.14; Tue, 23 Mar 2021 01:36:38 -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 S229897AbhCWIfm (ORCPT + 99 others); Tue, 23 Mar 2021 04:35:42 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:37920 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhCWIfe (ORCPT ); Tue, 23 Mar 2021 04:35:34 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0UT38Cws_1616488528; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UT38Cws_1616488528) by smtp.aliyun-inc.com(127.0.0.1); Tue, 23 Mar 2021 16:35:29 +0800 From: Tianjia Zhang To: David Howells , David Woodhouse , Jonathan Corbet , Herbert Xu , "David S. Miller" , Masahiro Yamada , Andrew Morton , Nathan Chancellor , Kees Cook , Nick Desaulniers , Valentin Schneider , Nick Terrell , KP Singh , Johannes Weiner , Vlastimil Babka , keyrings@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Jia Zhang Cc: Tianjia Zhang Subject: [PATCH] init/Kconfig: Support sign module with SM3 hash algorithm Date: Tue, 23 Mar 2021 16:35:28 +0800 Message-Id: <20210323083528.25678-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The kernel module signature supports the option to use the SM3 secure hash (OSCCA GM/T 0004-2012 SM3). Signed-off-by: Tianjia Zhang --- Documentation/admin-guide/module-signing.rst | 5 +++-- crypto/asymmetric_keys/pkcs7_parser.c | 7 +++++++ init/Kconfig | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/module-signing.rst b/Documentation/admin-guide/module-signing.rst index 7d7c7c8a545c..8d8980808b5b 100644 --- a/Documentation/admin-guide/module-signing.rst +++ b/Documentation/admin-guide/module-signing.rst @@ -30,8 +30,8 @@ This facility uses X.509 ITU-T standard certificates to encode the public keys involved. The signatures are not themselves encoded in any industrial standard type. The facility currently only supports the RSA public key encryption standard (though it is pluggable and permits others to be used). The possible -hash algorithms that can be used are SHA-1, SHA-224, SHA-256, SHA-384, and -SHA-512 (the algorithm is selected by data in the signature). +hash algorithms that can be used are SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, +and SM3 (the algorithm is selected by data in the signature). ========================== @@ -86,6 +86,7 @@ This has a number of options available: ``CONFIG_MODULE_SIG_SHA256`` :menuselection:`Sign modules with SHA-256` ``CONFIG_MODULE_SIG_SHA384`` :menuselection:`Sign modules with SHA-384` ``CONFIG_MODULE_SIG_SHA512`` :menuselection:`Sign modules with SHA-512` + ``CONFIG_MODULE_SIG_SM3`` :menuselection:`Sign modules with SM3` =============================== ========================================== The algorithm selected here will also be built into the kernel (rather diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c index 967329e0a07b..6cf6c4552c11 100644 --- a/crypto/asymmetric_keys/pkcs7_parser.c +++ b/crypto/asymmetric_keys/pkcs7_parser.c @@ -248,6 +248,9 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen, case OID_sha224: ctx->sinfo->sig->hash_algo = "sha224"; break; + case OID_sm3: + ctx->sinfo->sig->hash_algo = "sm3"; + break; default: printk("Unsupported digest algo: %u\n", ctx->last_oid); return -ENOPKG; @@ -269,6 +272,10 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen, ctx->sinfo->sig->pkey_algo = "rsa"; ctx->sinfo->sig->encoding = "pkcs1"; break; + case OID_SM2_with_SM3: + ctx->sinfo->sig->pkey_algo = "sm2"; + ctx->sinfo->sig->encoding = "raw"; + break; default: printk("Unsupported pkey algo: %u\n", ctx->last_oid); return -ENOPKG; diff --git a/init/Kconfig b/init/Kconfig index 5f5c776ef192..fed9236078e4 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2202,6 +2202,10 @@ config MODULE_SIG_SHA512 bool "Sign modules with SHA-512" select CRYPTO_SHA512 +config MODULE_SIG_SM3 + bool "Sign modules with SM3" + select CRYPTO_SM3 + endchoice config MODULE_SIG_HASH @@ -2212,6 +2216,7 @@ config MODULE_SIG_HASH default "sha256" if MODULE_SIG_SHA256 default "sha384" if MODULE_SIG_SHA384 default "sha512" if MODULE_SIG_SHA512 + default "sm3" if MODULE_SIG_SM3 config MODULE_COMPRESS bool "Compress modules on installation" -- 2.19.1.3.ge56e4f7