2022-06-27 09:25:24

by Tianjia Zhang

[permalink] [raw]
Subject: [PATCH v2] X.509: Support parsing certificate using SM2 algorithm

The SM2-with-SM3 certificate generated by latest openssl no longer
reuses the OID_id_ecPublicKey, but directly uses OID_sm2. This patch
supports this type of x509 certificate parsing.

Signed-off-by: Tianjia Zhang <[email protected]>
Acked-by: Jarkko Sakkinen <[email protected]>
---
crypto/asymmetric_keys/x509_cert_parser.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 2899ed80bb18..7a9b084e2043 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -508,6 +508,9 @@ int x509_extract_key_data(void *context, size_t hdrlen,
case OID_gost2012PKey512:
ctx->cert->pub->pkey_algo = "ecrdsa";
break;
+ case OID_sm2:
+ ctx->cert->pub->pkey_algo = "sm2";
+ break;
case OID_id_ecPublicKey:
if (parse_OID(ctx->params, ctx->params_size, &oid) != 0)
return -EBADMSG;
--
2.24.3 (Apple Git-128)


2022-06-27 23:20:49

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH v2] X.509: Support parsing certificate using SM2 algorithm

On Mon, Jun 27, 2022 at 05:19:58PM +0800, Tianjia Zhang wrote:
> The SM2-with-SM3 certificate generated by latest openssl no longer
> reuses the OID_id_ecPublicKey, but directly uses OID_sm2. This patch
> supports this type of x509 certificate parsing.
>
> Signed-off-by: Tianjia Zhang <[email protected]>
> Acked-by: Jarkko Sakkinen <[email protected]>
> ---
> crypto/asymmetric_keys/x509_cert_parser.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
> index 2899ed80bb18..7a9b084e2043 100644
> --- a/crypto/asymmetric_keys/x509_cert_parser.c
> +++ b/crypto/asymmetric_keys/x509_cert_parser.c
> @@ -508,6 +508,9 @@ int x509_extract_key_data(void *context, size_t hdrlen,
> case OID_gost2012PKey512:
> ctx->cert->pub->pkey_algo = "ecrdsa";
> break;
> + case OID_sm2:
> + ctx->cert->pub->pkey_algo = "sm2";
> + break;
> case OID_id_ecPublicKey:
> if (parse_OID(ctx->params, ctx->params_size, &oid) != 0)
> return -EBADMSG;
> --
> 2.24.3 (Apple Git-128)
>

Thanks, I can pick this.

BR, Jarkko