summaryrefslogtreecommitdiff
path: root/lib/libcrypto/evp
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-09-10 16:53:57 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-09-10 16:53:57 +0000
commit2ae37346b47316e18a42a837a11a721abbd24d09 (patch)
tree4633ca4fbac4dbddb5c512d59b6932ac7860ee2f /lib/libcrypto/evp
parent265d048fa59273f8e98923ebc5500edc649386b1 (diff)
EVP_CipherInit(): use EVP_CIPHER_CTX_cleanup()
Before EVP_CIPHER_CTX was opaque, callers could pass an uninitialized ctx into EVP_CipherInit() and calling EVP_CIPHER_CTX_cleanup() on such a ctx would end in tears. The only way to initialize a ctx is by way of EVP_CIPHER_CTX_new(), on which we can call EVP_CIPHER_CTX_cleanup() and avoid silly leaks on ctx reuse. This also allows some simplifications in the documentation. There are more changes of this kind that should be done all over libcrypto. They will be tackled in subsequent commits. "makes a lot of sense" schwarze ok jsing
Diffstat (limited to 'lib/libcrypto/evp')
-rw-r--r--lib/libcrypto/evp/evp_enc.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c
index 27f753baa07..7534b4c9d27 100644
--- a/lib/libcrypto/evp/evp_enc.c
+++ b/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp_enc.c,v 1.52 2023/07/07 19:37:53 beck Exp $ */
+/* $OpenBSD: evp_enc.c,v 1.53 2023/09/10 16:53:56 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -78,8 +78,8 @@ int
EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
const unsigned char *key, const unsigned char *iv, int enc)
{
- if (cipher)
- EVP_CIPHER_CTX_init(ctx);
+ if (cipher != NULL)
+ EVP_CIPHER_CTX_cleanup(ctx);
return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
}