From 36927f0810592c4aa717de154af64ab516606fbe Mon Sep 17 00:00:00 2001 From: david Date: Sun, 28 Mar 2010 21:18:02 +0000 Subject: [PATCH] Fix a problem in the changes to the openssl NSE library made in r17002 found by Patrik Karlsson. The second and subsequent times we call EVP{Encrypt,Decrypt}Init_ex, we have to pass NULL for the type argument. This allows setting to accumulate from previous calls. --- nse_openssl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nse_openssl.cc b/nse_openssl.cc index 949e5b955..1cc657a8d 100644 --- a/nse_openssl.cc +++ b/nse_openssl.cc @@ -393,7 +393,7 @@ static int l_encrypt(lua_State *L) /** encrypt( string algorithm, string key, st if (!out) return luaL_error( L, "Couldn't allocate memory."); if (!( - EVP_EncryptInit_ex( &cipher_ctx, evp_cipher, NULL, key, iv ) && + EVP_EncryptInit_ex( &cipher_ctx, NULL, NULL, key, iv ) && EVP_EncryptUpdate( &cipher_ctx, out, &out_len, data, data_len ) && EVP_EncryptFinal_ex( &cipher_ctx, out + out_len, &final_len ) )) { EVP_CIPHER_CTX_cleanup( &cipher_ctx ); @@ -447,7 +447,7 @@ static int l_decrypt(lua_State *L) /** decrypt( string algorithm, string key, st if (!out) return luaL_error( L, "Couldn't allocate memory."); if (!( - EVP_DecryptInit_ex( &cipher_ctx, evp_cipher, NULL, key, iv ) && + EVP_DecryptInit_ex( &cipher_ctx, NULL, NULL, key, iv ) && EVP_DecryptUpdate( &cipher_ctx, out, &out_len, data, data_len ) && EVP_DecryptFinal_ex( &cipher_ctx, out + out_len, &final_len ) )) { EVP_CIPHER_CTX_cleanup( &cipher_ctx );