summaryrefslogtreecommitdiff
path: root/providers
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-04-06 10:03:22 +0200
committerTomas Mraz <tomas@openssl.org>2022-04-11 11:45:04 +0200
commit2904d0a2ae0ec6ce23d5cec66ce8c7bdb005d4e5 (patch)
treebfc2b98fb386c36cd81acddb41c5fa87aded310e /providers
parent5f1424c6bdca8ddb9d5d88a78a1d738be19c4ea8 (diff)
downloadopenssl-new-2904d0a2ae0ec6ce23d5cec66ce8c7bdb005d4e5.tar.gz
sm2: Allow setting 0 length SM2 dist ID param
Fixes #18022 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18052)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/signature/sm2_sig.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/providers/implementations/signature/sm2_sig.c b/providers/implementations/signature/sm2_sig.c
index 99460edfce..3de42f496e 100644
--- a/providers/implementations/signature/sm2_sig.c
+++ b/providers/implementations/signature/sm2_sig.c
@@ -430,7 +430,7 @@ static int sm2sig_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[])
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_DIST_ID);
if (p != NULL) {
void *tmp_id = NULL;
- size_t tmp_idlen;
+ size_t tmp_idlen = 0;
/*
* If the 'z' digest has already been computed, the ID is set too late
@@ -438,7 +438,8 @@ static int sm2sig_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[])
if (!psm2ctx->flag_compute_z_digest)
return 0;
- if (!OSSL_PARAM_get_octet_string(p, &tmp_id, 0, &tmp_idlen))
+ if (p->data_size != 0
+ && !OSSL_PARAM_get_octet_string(p, &tmp_id, 0, &tmp_idlen))
return 0;
OPENSSL_free(psm2ctx->id);
psm2ctx->id = tmp_id;