Blame SOURCES/winpr-crypto-Load-legacy-provider-to-fix-rc4-with-Op.patch

831591
From e1f63dba5c63302b8a5e9d33c9ffe5580105de72 Mon Sep 17 00:00:00 2001
831591
From: Ondrej Holy <oholy@redhat.com>
831591
Date: Tue, 3 Aug 2021 08:47:13 +0200
831591
Subject: [PATCH] winpr/crypto: Load legacy provider to fix rc4 with OpenSSL
831591
 3.0
831591
831591
Currently, the `EVP_EncryptInit_ex` function fails for rc4 with OpenSSL 3.0.
831591
This is becuase rc4 is provided by the legacy provider which is not loaded
831591
by default. Let's explicitly load the legacy provider to make FreeRDP work
831591
with OpenSSL 3.0.
831591
831591
Relates: https://github.com/openssl/openssl/issues/14392
831591
Fixes: https://github.com/FreeRDP/FreeRDP/issues/6604
831591
---
831591
 winpr/libwinpr/crypto/cipher.c | 9 +++++++++
831591
 1 file changed, 9 insertions(+)
831591
831591
diff --git a/winpr/libwinpr/crypto/cipher.c b/winpr/libwinpr/crypto/cipher.c
831591
index bd52cfeed..75d25a1c7 100644
831591
--- a/winpr/libwinpr/crypto/cipher.c
831591
+++ b/winpr/libwinpr/crypto/cipher.c
831591
@@ -29,6 +29,9 @@
831591
 #include <openssl/rc4.h>
831591
 #include <openssl/des.h>
831591
 #include <openssl/evp.h>
831591
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
831591
+#include <openssl/provider.h>
831591
+#endif
831591
 #endif
831591
 
831591
 #ifdef WITH_MBEDTLS
831591
@@ -58,6 +60,11 @@ static WINPR_RC4_CTX* winpr_RC4_New_Internal(const BYTE* key, size_t keylen, BOO
831591
 
831591
 #if defined(WITH_OPENSSL)
831591
 
831591
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
831591
+	if (OSSL_PROVIDER_load(NULL, "legacy") == NULL)
831591
+		return NULL;
831591
+#endif
831591
+
831591
 	if (!(ctx = (WINPR_RC4_CTX*)EVP_CIPHER_CTX_new()))
831591
 		return NULL;
831591
 
831591
-- 
831591
2.31.1
831591