From 67953fd96cb2acab09adea7ed290557f83a15d57 Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 25 Mar 2024 11:41:40 +0000 Subject: [PATCH] Inline sctx in EVP_DigestSignFinal ok tb@ jsing@ --- lib/libcrypto/evp/m_sigver.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/libcrypto/evp/m_sigver.c b/lib/libcrypto/evp/m_sigver.c index b9f77afc116..f89f6034bf5 100644 --- a/lib/libcrypto/evp/m_sigver.c +++ b/lib/libcrypto/evp/m_sigver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_sigver.c,v 1.17 2024/03/25 11:10:17 joshua Exp $ */ +/* $OpenBSD: m_sigver.c,v 1.18 2024/03/25 11:41:40 joshua Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -171,16 +171,11 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) { EVP_PKEY_CTX *pctx = ctx->pctx; - int sctx; int r = 0; if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) return evp_digestsignfinal_sigctx_custom(ctx, sigret, siglen); - if (ctx->pctx->pmeth->signctx) - sctx = 1; - else - sctx = 0; if (sigret) { EVP_MD_CTX tmp_ctx; unsigned char md[EVP_MAX_MD_SIZE]; @@ -188,18 +183,20 @@ EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) EVP_MD_CTX_legacy_clear(&tmp_ctx); if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) return 0; - if (sctx) + if (ctx->pctx->pmeth->signctx != NULL) { r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, sigret, siglen, &tmp_ctx); - else - r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); + EVP_MD_CTX_cleanup(&tmp_ctx); + return r; + } + r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); EVP_MD_CTX_cleanup(&tmp_ctx); - if (sctx || !r) + if (!r) return r; if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) return 0; } else { - if (sctx) { + if (ctx->pctx->pmeth->signctx != NULL) { if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx) <= 0) return 0; -- 2.20.1