Commit 7703de2772 for openssl.org
commit 7703de27725892036051082b28062be15130c9d9
Author: Dr. David von Oheimb <dev@ddvo.net>
Date: Mon Jul 14 19:51:14 2025 +0200
cmp_ctx_set_md(): on error, provide name of unsupported algorithm
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Tue Mar 24 17:06:58 2026
(Merged from https://github.com/openssl/openssl/pull/29074)
diff --git a/crypto/cmp/cmp_ctx.c b/crypto/cmp/cmp_ctx.c
index 28f9a77e8f..e3991d0e39 100644
--- a/crypto/cmp/cmp_ctx.c
+++ b/crypto/cmp/cmp_ctx.c
@@ -81,11 +81,18 @@ err:
static int cmp_ctx_set_md(OSSL_CMP_CTX *ctx, EVP_MD **pmd, int nid)
{
- EVP_MD *md = EVP_MD_fetch(ctx->libctx, OBJ_nid2sn(nid), ctx->propq);
+ const char *name = OBJ_nid2sn(nid);
+ EVP_MD *md;
+
+ if (name == NULL) {
+ ERR_raise_data(ERR_LIB_CMP, CMP_R_UNKNOWN_ALGORITHM_ID, "nid=%d", nid);
+ return 0;
+ }
+ md = EVP_MD_fetch(ctx->libctx, name, ctx->propq);
/* fetching in advance to be able to throw error early if unsupported */
if (md == NULL) {
- ERR_raise(ERR_LIB_CMP, CMP_R_UNSUPPORTED_ALGORITHM);
+ ERR_raise_data(ERR_LIB_CMP, CMP_R_UNSUPPORTED_ALGORITHM, "name=%s,nid=%d", name, nid);
return 0;
}
EVP_MD_free(*pmd);