summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-03-27 07:36:59 +0000
committertb <>2024-03-27 07:36:59 +0000
commitddd9b2994f4684a973bc70f1ebcfc1cb05c2c215 (patch)
tree1e172b3a5a2b894938557148895db2beeb9efc9f /src/lib
parent4a090dcddc4e480cc9636bb614e5025ba6ddc61d (diff)
downloadopenbsd-ddd9b2994f4684a973bc70f1ebcfc1cb05c2c215.tar.gz
openbsd-ddd9b2994f4684a973bc70f1ebcfc1cb05c2c215.tar.bz2
openbsd-ddd9b2994f4684a973bc70f1ebcfc1cb05c2c215.zip
Explain the weird copy dance in EVP_DigestSignFinal()
with jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/evp/m_sigver.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c
index 090134c40c..d427e05db0 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.25 2024/03/27 06:53:15 tb Exp $ */ 1/* $OpenBSD: m_sigver.c,v 1.26 2024/03/27 07:36:59 tb 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 */
@@ -191,7 +191,7 @@ EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
191 return 1; 191 return 1;
192 } 192 }
193 193
194 194 /* Use a copy since EVP_DigestFinal_ex() clears secrets. */
195 if ((md_ctx = EVP_MD_CTX_new()) == NULL) 195 if ((md_ctx = EVP_MD_CTX_new()) == NULL)
196 goto err; 196 goto err;
197 if (!EVP_MD_CTX_copy_ex(md_ctx, ctx)) 197 if (!EVP_MD_CTX_copy_ex(md_ctx, ctx))
@@ -203,6 +203,7 @@ EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen)
203 } else { 203 } else {
204 if (!EVP_DigestFinal_ex(md_ctx, md, &mdlen)) 204 if (!EVP_DigestFinal_ex(md_ctx, md, &mdlen))
205 goto err; 205 goto err;
206 /* Use the original ctx since secrets were cleared. */
206 if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0) 207 if (EVP_PKEY_sign(ctx->pctx, sigret, siglen, md, mdlen) <= 0)
207 goto err; 208 goto err;
208 } 209 }