aboutsummaryrefslogtreecommitdiff
path: root/src/common/Cryptography/ARC4.cpp
diff options
context:
space:
mode:
authordaMaex <damaex@live.de>2022-06-14 21:39:22 +0200
committerShauren <shauren.trinity@gmail.com>2022-09-05 18:44:05 +0200
commit13c44517da23d6e1adf2cb9b526d3181516a1cb2 (patch)
tree1f86db0f106ef59555643574ae1b4ae6c970817a /src/common/Cryptography/ARC4.cpp
parent95997cd56f8e9ef134aa7c07c7436397122e2717 (diff)
Core/Crypto: Updated ARC4 code with openssl 3.0 support
(cherry picked from commit 9fca5e9117317d6706fdf7d09fb86acaa3361129)
Diffstat (limited to 'src/common/Cryptography/ARC4.cpp')
-rw-r--r--src/common/Cryptography/ARC4.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/common/Cryptography/ARC4.cpp b/src/common/Cryptography/ARC4.cpp
index 161303e2c15..faa2265ef71 100644
--- a/src/common/Cryptography/ARC4.cpp
+++ b/src/common/Cryptography/ARC4.cpp
@@ -18,16 +18,35 @@
#include "ARC4.h"
#include "Errors.h"
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+#include <openssl/provider.h>
+#endif
+
Trinity::Crypto::ARC4::ARC4() : _ctx(EVP_CIPHER_CTX_new())
{
+ EVP_CIPHER const* cipher;
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ _libCtx = OSSL_LIB_CTX_new();
+ _legacyProvider = OSSL_PROVIDER_load(_libCtx, "legacy");
+
+ cipher = EVP_CIPHER_fetch(_libCtx, "RC4", "");
+#else
+ cipher = EVP_rc4();
+#endif
+
EVP_CIPHER_CTX_init(_ctx);
- int result = EVP_EncryptInit_ex(_ctx, EVP_rc4(), nullptr, nullptr, nullptr);
+ int result = EVP_EncryptInit_ex(_ctx, cipher, nullptr, nullptr, nullptr);
ASSERT(result == 1);
}
Trinity::Crypto::ARC4::~ARC4()
{
EVP_CIPHER_CTX_free(_ctx);
+
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ OSSL_PROVIDER_unload(_legacyProvider);
+ OSSL_LIB_CTX_free(_libCtx);
+#endif
}
void Trinity::Crypto::ARC4::Init(uint8 const* seed, size_t len)