diff options
author | lan1120 <lanming@huawei.com> | 2024-09-30 09:00:04 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-10-07 17:35:28 +0200 |
commit | b69ca92a5e61745dc0e74bb5c1eef75e8b45f83f (patch) | |
tree | 800f2623289f9e208a9f2c250d286837a41e75c6 /providers | |
parent | Update test/quic-openssl-docker/run_endpoint.sh (diff) | |
download | openssl-b69ca92a5e61745dc0e74bb5c1eef75e8b45f83f.tar.xz openssl-b69ca92a5e61745dc0e74bb5c1eef75e8b45f83f.zip |
Drop the aid field of the signature prov ctx
Signed-off-by: lan1120 <lanming@huawei.com>
Reviewed-by: Hugo Landau <hlandau@devever.net>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23094)
Diffstat (limited to 'providers')
-rw-r--r-- | providers/implementations/signature/dsa_sig.c | 10 | ||||
-rw-r--r-- | providers/implementations/signature/ecdsa_sig.c | 11 | ||||
-rw-r--r-- | providers/implementations/signature/eddsa_sig.c | 12 | ||||
-rw-r--r-- | providers/implementations/signature/sm2_sig.c | 10 |
4 files changed, 30 insertions, 13 deletions
diff --git a/providers/implementations/signature/dsa_sig.c b/providers/implementations/signature/dsa_sig.c index 45dc235832..eb28c595b7 100644 --- a/providers/implementations/signature/dsa_sig.c +++ b/providers/implementations/signature/dsa_sig.c @@ -98,7 +98,6 @@ typedef struct { /* The Algorithm Identifier of the combined signature algorithm */ unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; - unsigned char *aid; size_t aid_len; /* main digest */ @@ -160,6 +159,7 @@ static int dsa_setup_md(PROV_DSA_CTX *ctx, WPACKET pkt; int md_nid; size_t mdname_len = strlen(mdname); + unsigned char *aid = NULL; md = EVP_MD_fetch(ctx->libctx, mdname, mdprops); md_nid = ossl_digest_get_approved_nid(md); @@ -223,9 +223,11 @@ static int dsa_setup_md(PROV_DSA_CTX *ctx, md_nid) && WPACKET_finish(&pkt)) { WPACKET_get_total_written(&pkt, &ctx->aid_len); - ctx->aid = WPACKET_get_curr(&pkt); + aid = WPACKET_get_curr(&pkt); } WPACKET_cleanup(&pkt); + if (aid != NULL && ctx->aid_len != 0) + memmove(ctx->aid_buf, aid, ctx->aid_len); ctx->mdctx = NULL; ctx->md = md; @@ -674,7 +676,9 @@ static int dsa_get_ctx_params(void *vpdsactx, OSSL_PARAM *params) p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); if (p != NULL - && !OSSL_PARAM_set_octet_string(p, pdsactx->aid, pdsactx->aid_len)) + && !OSSL_PARAM_set_octet_string(p, + pdsactx->aid_len == 0 ? NULL : pdsactx->aid_buf, + pdsactx->aid_len)) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST); diff --git a/providers/implementations/signature/ecdsa_sig.c b/providers/implementations/signature/ecdsa_sig.c index 52607245a4..72be2bcb62 100644 --- a/providers/implementations/signature/ecdsa_sig.c +++ b/providers/implementations/signature/ecdsa_sig.c @@ -95,7 +95,6 @@ typedef struct { /* The Algorithm Identifier of the combined signature algorithm */ unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; - unsigned char *aid; size_t aid_len; /* main digest */ @@ -172,6 +171,7 @@ static int ecdsa_setup_md(PROV_ECDSA_CTX *ctx, size_t mdname_len; int md_nid, md_size; WPACKET pkt; + unsigned char *aid = NULL; if (mdname == NULL) return 1; @@ -242,9 +242,12 @@ static int ecdsa_setup_md(PROV_ECDSA_CTX *ctx, md_nid) && WPACKET_finish(&pkt)) { WPACKET_get_total_written(&pkt, &ctx->aid_len); - ctx->aid = WPACKET_get_curr(&pkt); + aid = WPACKET_get_curr(&pkt); } WPACKET_cleanup(&pkt); + if (aid != NULL && ctx->aid_len != 0) + memmove(ctx->aid_buf, aid, ctx->aid_len); + ctx->mdctx = NULL; ctx->md = md; ctx->mdsize = (size_t)md_size; @@ -670,7 +673,9 @@ static int ecdsa_get_ctx_params(void *vctx, OSSL_PARAM *params) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); - if (p != NULL && !OSSL_PARAM_set_octet_string(p, ctx->aid, ctx->aid_len)) + if (p != NULL && !OSSL_PARAM_set_octet_string(p, + ctx->aid_len == 0 ? NULL : ctx->aid_buf, + ctx->aid_len)) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE); diff --git a/providers/implementations/signature/eddsa_sig.c b/providers/implementations/signature/eddsa_sig.c index 395d4b4daf..e6689911c8 100644 --- a/providers/implementations/signature/eddsa_sig.c +++ b/providers/implementations/signature/eddsa_sig.c @@ -141,7 +141,6 @@ typedef struct { /* The Algorithm Identifier of the signature algorithm */ unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; - unsigned char *aid; size_t aid_len; /* id indicating the EdDSA instance */ @@ -234,6 +233,7 @@ static int eddsa_signverify_init(void *vpeddsactx, void *vedkey) ECX_KEY *edkey = (ECX_KEY *)vedkey; WPACKET pkt; int ret; + unsigned char *aid = NULL; if (!ossl_prov_is_running()) return 0; @@ -281,9 +281,11 @@ static int eddsa_signverify_init(void *vpeddsactx, void *vedkey) } if (ret && WPACKET_finish(&pkt)) { WPACKET_get_total_written(&pkt, &peddsactx->aid_len); - peddsactx->aid = WPACKET_get_curr(&pkt); + aid = WPACKET_get_curr(&pkt); } WPACKET_cleanup(&pkt); + if (aid != NULL && peddsactx->aid_len != 0) + memmove(peddsactx->aid_buf, aid, peddsactx->aid_len); return 1; } @@ -795,8 +797,10 @@ static int eddsa_get_ctx_params(void *vpeddsactx, OSSL_PARAM *params) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); - if (p != NULL && !OSSL_PARAM_set_octet_string(p, peddsactx->aid, - peddsactx->aid_len)) + if (p != NULL + && !OSSL_PARAM_set_octet_string(p, + peddsactx->aid_len == 0 ? NULL : peddsactx->aid_buf, + peddsactx->aid_len)) return 0; return 1; diff --git a/providers/implementations/signature/sm2_sig.c b/providers/implementations/signature/sm2_sig.c index ec7c4af389..fa7dcefaa3 100644 --- a/providers/implementations/signature/sm2_sig.c +++ b/providers/implementations/signature/sm2_sig.c @@ -77,7 +77,6 @@ typedef struct { /* The Algorithm Identifier of the combined signature algorithm */ unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; - unsigned char *aid; size_t aid_len; /* main digest */ @@ -213,6 +212,7 @@ static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname, int md_nid; WPACKET pkt; int ret = 0; + unsigned char *aid = NULL; if (!sm2sig_signature_init(vpsm2ctx, ec, params) || !sm2sig_set_mdname(ctx, mdname)) @@ -238,9 +238,11 @@ static int sm2sig_digest_signverify_init(void *vpsm2ctx, const char *mdname, && ossl_DER_w_algorithmIdentifier_SM2_with_MD(&pkt, -1, ctx->ec, md_nid) && WPACKET_finish(&pkt)) { WPACKET_get_total_written(&pkt, &ctx->aid_len); - ctx->aid = WPACKET_get_curr(&pkt); + aid = WPACKET_get_curr(&pkt); } WPACKET_cleanup(&pkt); + if (aid != NULL && ctx->aid_len != 0) + memmove(ctx->aid_buf, aid, ctx->aid_len); if (!EVP_DigestInit_ex2(ctx->mdctx, ctx->md, params)) goto error; @@ -404,7 +406,9 @@ static int sm2sig_get_ctx_params(void *vpsm2ctx, OSSL_PARAM *params) p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); if (p != NULL - && !OSSL_PARAM_set_octet_string(p, psm2ctx->aid, psm2ctx->aid_len)) + && !OSSL_PARAM_set_octet_string(p, + psm2ctx->aid_len == 0 ? NULL : psm2ctx->aid_buf, + psm2ctx->aid_len)) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST_SIZE); |