[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] wrapper: move EVP_CIPHER_CTX_free call to libcrypto.c


From 2a6b43c86832cc4d601c816daf2fba0e2181227d Mon Sep 17 00:00:00 2001
From: Jon Simons <jon@xxxxxxxxxxxxx>
Date: Fri, 14 Jul 2017 19:47:48 -0400
Subject: [PATCH 3/3] 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 <jon@xxxxxxxxxxxxx>
---
 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) {
-- 
2.13.2


Archive administrator: postmaster@lists.cynapses.org