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 <tianjia.zhang@linux.alibaba.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
This commit is contained in:
Tianjia Zhang 2022-06-27 17:19:58 +08:00 committed by Jarkko Sakkinen
parent bbc23a07b0
commit 74ad4334b2
1 changed files with 3 additions and 0 deletions

View File

@ -508,6 +508,9 @@ int x509_extract_key_data(void *context, size_t hdrlen,
case OID_gost2012PKey512: case OID_gost2012PKey512:
ctx->cert->pub->pkey_algo = "ecrdsa"; ctx->cert->pub->pkey_algo = "ecrdsa";
break; break;
case OID_sm2:
ctx->cert->pub->pkey_algo = "sm2";
break;
case OID_id_ecPublicKey: case OID_id_ecPublicKey:
if (parse_OID(ctx->params, ctx->params_size, &oid) != 0) if (parse_OID(ctx->params, ctx->params_size, &oid) != 0)
return -EBADMSG; return -EBADMSG;