From 0986fee58b002cd25bde682945b8cf692fcb6fbe Mon Sep 17 00:00:00 2001 From: Will Cosgrove Date: Wed, 2 Nov 2022 09:28:45 -0700 Subject: [PATCH] Revert usage of EVP_CipherUpdate #764 #739 (#765) Revert usage of EVP_CipherUpdate from wolfSSL PR to fix #764 #739. --- src/openssl.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/openssl.c b/src/openssl.c index ef56e938..8e75833e 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -473,20 +473,28 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx, { unsigned char buf[EVP_MAX_BLOCK_LENGTH]; int ret; - int outlen; + int rc = 1; (void) algo; (void) encrypt; #ifdef HAVE_OPAQUE_STRUCTS - ret = EVP_CipherUpdate(*ctx, buf, &outlen, block, blocksize); + ret = EVP_Cipher(*ctx, buf, block, blocksize); #else - ret = EVP_CipherUpdate(ctx, buf, &outlen, block, blocksize); + ret = EVP_Cipher(ctx, buf, block, blocksize); #endif - if(ret == 1) { + +#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) || \ + defined(LIBSSH2_WOLFSSL) + if(ret != -1) +#else + if(ret == 1) +#endif + { + rc = 0; memcpy(block, buf, blocksize); } - return ret == 1 ? 0 : 1; + return rc; } #if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR)