Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp966646ybz; Wed, 15 Apr 2020 23:40:10 -0700 (PDT) X-Google-Smtp-Source: APiQypKHZT66rmpU9/qHdcH9xrbK6bd0pVsM0Wxt6qEbzWxsIEtNe8NGjvTqGUAbNB/y8FDaGzO3 X-Received: by 2002:a17:906:2b96:: with SMTP id m22mr7659334ejg.330.1587019209871; Wed, 15 Apr 2020 23:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587019209; cv=none; d=google.com; s=arc-20160816; b=GGE6BmS61vh3vovj5xz9NIQEidZsp9Jt+H1FejZ14KS5zJ0GbgSEJrxU1aJwCaYeG3 TdCWLZ4YmT2wwKZa5P1rb/+viByepe0c9acay9UFyX78RapaGUB1shGQjlWpFKGFQbEv wv2ZQZpTtL60lk7Keljqb5DNtR0I/Bps/neMXeOBVa66I9WWRg8A/GJva4PqMiDXtVym MIVjK1ScYEoy7Ls6LTrvJr/9j1bp8u3ko5uYKw/Qko/yDYPPXN1jKkVAHsuUdjwoDft5 VJUrJ1GFebXT5GJe9woMg9CRpYjr9ZGgnh8xruVe9WcT21Fqj+6VZmQZ6xJET5f/yZDo ZtJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=/aKi3CLpp3Mz+oDcBdzogYwfaYBBSGBfXpNlHzaLVt0=; b=zhXWn318Wy1EFzfgdkDFh+LkjB//Ka86TmWhSM/v5lQZz71eaEWVddbFBmQFpTlTKL UOnDYmQqov65pmu3rjcfYMA/ncts0BoubhqXH34HZptnHihxLIT4EerIwn6Es3cJF4wq XLNadC7cTTqGET1qmDm6j9xvHjWh7yTTgsk71+Rz2ywBeJTmZkHzboq55RGx41ldmH1r ssGXNsfXR3dHB/IA51uty8px/+7PBcMdorMJBM3QMx+T7d7bippwD+2drmKT1VEKXHbW H4LefQkDCQQzoGf9+j+ArEEKQiVgbMx+z2EdzLJFl4z9cCkE6o2rLQ1RelINrN1gqLQ6 I9sQ== 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 d16si8226332edr.480.2020.04.15.23.39.46; Wed, 15 Apr 2020 23:40:09 -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 S2408149AbgDPGig (ORCPT + 99 others); Thu, 16 Apr 2020 02:38:36 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:51864 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408304AbgDPGiU (ORCPT ); Thu, 16 Apr 2020 02:38:20 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0TvgSr.7_1587019046; Received: from 30.27.118.45(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0TvgSr.7_1587019046) by smtp.aliyun-inc.com(127.0.0.1); Thu, 16 Apr 2020 14:37:27 +0800 Subject: Re: [PATCH v2 0/7] crpyto: introduce OSCCA certificate and SM2 asymmetric algorithm To: Herbert Xu Cc: davem@davemloft.net, ebiggers@kernel.org, ebiggers@google.com, pvanleeuwen@rambus.com, zohar@linux.ibm.com, gilad@benyossef.com, jarkko.sakkinen@linux.intel.com, dmitry.kasatkin@intel.com, nicstange@gmail.com, tadeusz.struk@intel.com, jmorris@namei.org, serge@hallyn.com, zhang.jia@linux.alibaba.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200402123504.84628-1-tianjia.zhang@linux.alibaba.com> <20200416060136.GA19149@gondor.apana.org.au> From: Tianjia Zhang Message-ID: Date: Thu, 16 Apr 2020 14:37:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200416060136.GA19149@gondor.apana.org.au> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/16 14:01, Herbert Xu wrote: > On Thu, Apr 02, 2020 at 08:34:57PM +0800, Tianjia Zhang wrote: >> Hello all, >> >> This new module implement the OSCCA certificate and SM2 public key >> algorithm. It was published by State Encryption Management Bureau, China. >> List of specifications for OSCCA certificate and SM2 elliptic curve >> public key cryptography: >> >> * GM/T 0003.1-2012 >> * GM/T 0003.2-2012 >> * GM/T 0003.3-2012 >> * GM/T 0003.4-2012 >> * GM/T 0003.5-2012 >> * GM/T 0015-2012 >> * GM/T 0009-2012 >> >> IETF: https://tools.ietf.org/html/draft-shen-sm2-ecdsa-02 >> oscca: http://www.oscca.gov.cn/sca/xxgk/2010-12/17/content_1002386.shtml >> scctc: http://www.gmbz.org.cn/main/bzlb.html >> >> These patchs add the OID object identifier defined by OSCCA. The >> x509 certificate supports sm2-with-sm3 type certificate parsing >> and verification. > > I don't have any objections to the crypto API bits, but obviously > this is contingent on the x509 bits getting accepted since that's > the only in-kernel user. So can I see some acks on that please? > > Thanks, > Thanks for Herbert's reply. At present, the latest mainline openssl can generate SM2-with-SM3 certificates. I also provide commands for generating certificates and a test certificate in PEM format. ``` bash #!/bin/bash if [ ! -f openssl.cnf ]; then cat > openssl.cnf << EOF [ req ] default_bits = 2048 distinguished_name = req_distinguished_name prompt = no string_mask = utf8only x509_extensions = v3_req [ req_distinguished_name ] O = Test OU = Test CN = Test key emailAddress = test@foo.com [ v3_req ] basicConstraints=critical,CA:FALSE keyUsage=digitalSignature subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always EOF fi openssl ecparam -genkey -name SM2 -text -out private.pem openssl req -new \ -key private.pem \ -out csr.pem \ -sm3 -sigopt "distid:1234567812345678" \ -subj "/C=CN/ST=GS/L=Gt/O=baba/OU=OS/CN=hello/emailAddress=hello@world.com" openssl ecparam -genkey -name SM2 -text -out ca.key openssl req -new \ -x509 -days 3650 \ -sm3 -sigopt "distid:1234567812345678" \ -key ca.key \ -out ca.crt \ -subj "/C=CN/ST=GS/L=Gt/O=baba/OU=OS/CN=ca/emailAddress=ca@world.com" openssl x509 -req -days 3650 \ -sm3 \ -sigopt "distid:1234567812345678" \ -vfyopt "distid:1234567812345678" \ -CA ca.crt -CAkey ca.key -CAcreateserial \ -extfile openssl.cnf -extensions v3_req \ -in csr.pem \ -out cert.pem openssl x509 -in ca.crt -outform DER -out ca.der openssl x509 -in cert.pem -outform DER -out cert.der ``` The following content is the CA certificate and the signed SM2-with-SM3 certificate generated by the above command, both in PEM format. -----BEGIN CERTIFICATE----- MIICLjCCAdWgAwIBAgIUEoozP6LzMYWh4gCpcWlzsUyfgsIwCgYIKoEcz1UBg3Uw bTELMAkGA1UEBhMCQ04xCzAJBgNVBAgMAkdTMQswCQYDVQQHDAJHdDENMAsGA1UE CgwEYmFiYTELMAkGA1UECwwCT1MxCzAJBgNVBAMMAmNhMRswGQYJKoZIhvcNAQkB FgxjYUB3b3JsZC5jb20wHhcNMjAwNDE1MTE1NDA3WhcNMzAw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5pHCjXTBbMAwGA1UdEwEB/wQCMAAwCwYDVR0PBAQDAgeAMB0G A1UdDgQWBBQ76UB0skz7y4ic5V/PIWFLZ5XoDDAfBgNVHSMEGDAWgBSjd9GWIe98 Ll9J0dquxgCktp9DrTAKBggqgRzPVQGDdQNIADBFAiEA25WAmaN7g7M26lwMad4H AeO8YNSBOcHKc8AfCdYSS88CIBJji4xRm+wXCR9qkXj4g8HVhaYpvwlMukk9EYxw 09gJ -----END CERTIFICATE----- The following is the certificate information of SM2-with-SM3, the following command output: `openssl x509 -in cert.pem -noout -text` Certificate: Data: Version: 3 (0x2) Serial Number: 21:a6:b0:3f:91:d0:0e:2e:64:4e:bb:b2:84:bb:9d:15:f7:90:ee:ec Signature Algorithm: SM2-with-SM3 Issuer: C = CN, ST = GS, L = Gt, O = baba, OU = OS, CN = ca, emailAddress = ca@world.com Validity Not Before: Apr 15 11:54:07 2020 GMT Not After : Apr 13 11:54:07 2030 GMT Subject: C = CN, ST = GS, L = Gt, O = baba, OU = OS, CN = hello, emailAddress = hello@world.com Subject Public Key Info: Public Key Algorithm: id-ecPublicKey Public-Key: (256 bit) pub: 04:8e:a0:33:69:91:7e:3d:ec:ad:8e:f0:45:5e:13: 3e:68:5b:8c:ab:5c:c6:c8:50:df:91:00:e0:24:73: 4d:31:f2:2e:c0:d5:6b:ee:da:98:93:ec:d8:36:aa: b9:cf:63:82:ef:a7:1a:03:ed:16:ba:74:b8:8b:f9: e5:70:39:a4:70 ASN1 OID: SM2 X509v3 extensions: X509v3 Basic Constraints: critical CA:FALSE X509v3 Key Usage: Digital Signature X509v3 Subject Key Identifier: 3B:E9:40:74:B2:4C:FB:CB:88:9C:E5:5F:CF:21:61:4B:67:95:E8:0C X509v3 Authority Key Identifier: A3:77:D1:96:21:EF:7C:2E:5F:49:D1:DA:AE:C6:00:A4:B6:9F:43:AD Signature Algorithm: SM2-with-SM3 Signature Value: 30:45:02:21:00:db:95:80:99:a3:7b:83:b3:36:ea:5c:0c:69: de:07:01:e3:bc:60:d4:81:39:c1:ca:73:c0:1f:09:d6:12:4b: cf:02:20:12:63:8b:8c:51:9b:ec:17:09:1f:6a:91:78:f8:83: c1:d5:85:a6:29:bf:09:4c:ba:49:3d:11:8c:70:d3:d8:09 If additional information is needed, I can provide it. Thanks and best, Tianjia