summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoshua <>2024-03-25 11:41:40 +0000
committerjoshua <>2024-03-25 11:41:40 +0000
commitfd5bea87760bcaab02fc55b37bc5f9f2c003ce2e (patch)
tree3e9ae18037ec4a6954f930d18652cbcb799e60ca
parent3a30318a6378f6928646d6f17165f30cda65fc12 (diff)
downloadopenbsd-fd5bea87760bcaab02fc55b37bc5f9f2c003ce2e.tar.gz
openbsd-fd5bea87760bcaab02fc55b37bc5f9f2c003ce2e.tar.bz2
openbsd-fd5bea87760bcaab02fc55b37bc5f9f2c003ce2e.zip
Inline sctx in EVP_DigestSignFinal
ok tb@ jsing@
-rw-r--r--src/lib/libcrypto/evp/m_sigver.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c
index b9f77afc11..f89f6034bf 100644
--- a/src/lib/libcrypto/evp/m_sigver.c
+++ b/src/lib/libcrypto/evp/m_sigver.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: m_sigver.c,v 1.17 2024/03/25 11:10:17 joshua Exp $ */ 1/* $OpenBSD: m_sigver.c,v 1.18 2024/03/25 11:41:40 joshua Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -171,16 +171,11 @@ int
171EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) 171EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
172{ 172{
173 EVP_PKEY_CTX *pctx = ctx->pctx; 173 EVP_PKEY_CTX *pctx = ctx->pctx;
174 int sctx;
175 int r = 0; 174 int r = 0;
176 175
177 if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM) 176 if (pctx->pmeth->flags & EVP_PKEY_FLAG_SIGCTX_CUSTOM)
178 return evp_digestsignfinal_sigctx_custom(ctx, sigret, siglen); 177 return evp_digestsignfinal_sigctx_custom(ctx, sigret, siglen);
179 178
180 if (ctx->pctx->pmeth->signctx)
181 sctx = 1;
182 else
183 sctx = 0;
184 if (sigret) { 179 if (sigret) {
185 EVP_MD_CTX tmp_ctx; 180 EVP_MD_CTX tmp_ctx;
186 unsigned char md[EVP_MAX_MD_SIZE]; 181 unsigned char md[EVP_MAX_MD_SIZE];
@@ -188,18 +183,20 @@ EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
188 EVP_MD_CTX_legacy_clear(&tmp_ctx); 183 EVP_MD_CTX_legacy_clear(&tmp_ctx);
189 if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx)) 184 if (!EVP_MD_CTX_copy_ex(&tmp_ctx, ctx))
190 return 0; 185 return 0;
191 if (sctx) 186 if (ctx->pctx->pmeth->signctx != NULL) {
192 r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx, 187 r = tmp_ctx.pctx->pmeth->signctx(tmp_ctx.pctx,
193 sigret, siglen, &tmp_ctx); 188 sigret, siglen, &tmp_ctx);
194 else 189 EVP_MD_CTX_cleanup(&tmp_ctx);
195 r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen); 190 return r;
191 }
192 r = EVP_DigestFinal_ex(&tmp_ctx, md, &mdlen);
196 EVP_MD_CTX_cleanup(&tmp_ctx); 193 EVP_MD_CTX_cleanup(&tmp_ctx);
197 if (sctx || !r) 194 if (!r)
198 return r; 195 return r;
199 if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) 196 if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0)
200 return 0; 197 return 0;
201 } else { 198 } else {
202 if (sctx) { 199 if (ctx->pctx->pmeth->signctx != NULL) {
203 if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret, 200 if (ctx->pctx->pmeth->signctx(ctx->pctx, sigret,
204 siglen, ctx) <= 0) 201 siglen, ctx) <= 0)
205 return 0; 202 return 0;