From e66f370682927ca8bd7ae0e7544754c6f4ac4969 Mon Sep 17 00:00:00 2001 From: Jon Simons Date: Fri, 14 Jul 2017 19:47:48 -0400 Subject: [PATCH] wrapper: move EVP_CIPHER_CTX_free call to libcrypto.c With this change, a HAVE_LIBCRYPTO #ifdef is removed from wrapper.c. Now, the libcrypto-specific logic for EVP_CIPHER_CTX_free is moved into the ssh_cipher_struct cleanup callback handler for those ciphers. Signed-off-by: Jon Simons Reviewed-by: Andreas Schneider --- src/libcrypto.c | 3 +++ src/wrapper.c | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libcrypto.c b/src/libcrypto.c index 3bed5042..6a29c6e7 100644 --- a/src/libcrypto.c +++ b/src/libcrypto.c @@ -554,6 +554,9 @@ static void evp_cipher_decrypt(struct ssh_cipher_struct *cipher, static void evp_cipher_cleanup(struct ssh_cipher_struct *cipher) { EVP_CIPHER_CTX_cleanup(cipher->ctx); + if (cipher->ctx != NULL) { + EVP_CIPHER_CTX_free(cipher->ctx); + } } #ifndef HAVE_OPENSSL_EVP_AES_CTR diff --git a/src/wrapper.c b/src/wrapper.c index 8f30aeba..8ee04b49 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -124,12 +124,6 @@ void ssh_cipher_clear(struct ssh_cipher_struct *cipher){ if (cipher->cleanup != NULL) { cipher->cleanup(cipher); } - -#ifdef HAVE_LIBCRYPTO - if (cipher->ctx != NULL) { - EVP_CIPHER_CTX_free(cipher->ctx); - } -#endif } static void cipher_free(struct ssh_cipher_struct *cipher) {