summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp_digest.c
diff options
context:
space:
mode:
authortb <>2024-03-02 09:55:30 +0000
committertb <>2024-03-02 09:55:30 +0000
commit9154e84667bc426874bac49d55743f07fd005bc2 (patch)
tree1a29aa5a7674f289db524ae2d0ca6b1ffb7043b3 /src/lib/libcrypto/evp/evp_digest.c
parentd904a8f9d2ba21b2cd6d4e74ec8cd68927c5e6f9 (diff)
downloadopenbsd-9154e84667bc426874bac49d55743f07fd005bc2.tar.gz
openbsd-9154e84667bc426874bac49d55743f07fd005bc2.tar.bz2
openbsd-9154e84667bc426874bac49d55743f07fd005bc2.zip
Fix signature and semantics of EVP_{CIPHER,MD}_CTX_init()
When the EVP_CIPHER_CTX and the EVP_MD_CTX were still expected to live on the stack, these initialization APIs were wrappers around memset. In OpenSSL 1.1, somebody removed them and carelessly made _init() an alias of _reset() aka _cleanup(). As a consequence, both signature and semantics changed. Unsurprisingly, there is now code out there that actually uses the new semantics, which causes leaks on LibreSSL and older OpenSSL. This aligns our _init() with OpenSSL 1.1 semantics. ok jsing
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/evp/evp_digest.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libcrypto/evp/evp_digest.c b/src/lib/libcrypto/evp/evp_digest.c
index 3a349ad0e6..b8eedd429d 100644
--- a/src/lib/libcrypto/evp/evp_digest.c
+++ b/src/lib/libcrypto/evp/evp_digest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_digest.c,v 1.10 2024/02/18 15:45:42 tb Exp $ */ 1/* $OpenBSD: evp_digest.c,v 1.11 2024/03/02 09:55:30 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -247,15 +247,15 @@ EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
247} 247}
248 248
249void 249void
250EVP_MD_CTX_init(EVP_MD_CTX *ctx) 250EVP_MD_CTX_legacy_clear(EVP_MD_CTX *ctx)
251{ 251{
252 memset(ctx, 0, sizeof(*ctx)); 252 memset(ctx, 0, sizeof(*ctx));
253} 253}
254 254
255void 255int
256EVP_MD_CTX_legacy_clear(EVP_MD_CTX *ctx) 256EVP_MD_CTX_init(EVP_MD_CTX *ctx)
257{ 257{
258 memset(ctx, 0, sizeof(*ctx)); 258 return EVP_MD_CTX_cleanup(ctx);
259} 259}
260 260
261int 261int