From 35695772d0b93a50a1de79ced596be39062a48f1 Mon Sep 17 00:00:00 2001 From: Laurent Stacul Date: Mon, 3 May 2021 23:47:06 +0200 Subject: [PATCH] openssl.c: Fix EVP_Cipher interface change in openssl 3 #463 File: openssl.c Notes: Fixes building with OpenSSL 3, #463. The change is described there: https://github.com/openssl/openssl/commit/f7397f0d58ce7ddf4c5366cd1846f16b341fbe43 Credit: Laurent Stacul, reported by Sergei --- src/openssl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/openssl.c b/src/openssl.c index 65a6c173..c286bc61 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -427,10 +427,19 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx, #else ret = EVP_Cipher(ctx, buf, block, blocksize); #endif +#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3 + if(ret != -1) { +#else if(ret == 1) { +#endif memcpy(block, buf, blocksize); } + +#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3 + return ret != -1 ? 0 : 1; +#else return ret == 1 ? 0 : 1; +#endif } #if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR)