/* 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 */
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);
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;
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);
/* 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 */
size_t mdname_len;
int md_nid, md_size;
WPACKET pkt;
+ unsigned char *aid = NULL;
if (mdname == NULL)
return 1;
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;
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);
/* 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 */
ECX_KEY *edkey = (ECX_KEY *)vedkey;
WPACKET pkt;
int ret;
+ unsigned char *aid = NULL;
if (!ossl_prov_is_running())
return 0;
}
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;
}
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;
/* 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 */
int md_nid;
WPACKET pkt;
int ret = 0;
+ unsigned char *aid = NULL;
if (!sm2sig_signature_init(vpsm2ctx, ec, params)
|| !sm2sig_set_mdname(ctx, 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;
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);