Core/Crypto: Transitional Cryptography update for OpenSSL 1.1 (#21534)

Support for both OpenSSL 1.0 LTS and OpenSSL 1.1 versions.

Many Linux distributions are still on 1.0 and will stay on LTS for quite
some time.

Port of CMaNGOS commit: https://github.com/cmangos/mangos-wotlk/commit/e1b0048f052eda46bb27d20224d0339960816ac2
This commit is contained in:
Warlockbugs authored and Aokromes committed 2018-03-05 14:54:35 +01:00
1 parent ba65f58687
commit 6a8c0df9a8
5 files changed
+48 -34

No files matched your search

+15 -15
View File
@@ -18,34 +18,34 @@
#include "ARC4.h"
ARC4::ARC4(uint32 len) : m_ctx()
ARC4::ARC4(uint32 len) : m_ctx(EVP_CIPHER_CTX_new())
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
EVP_CIPHER_CTX_init(m_ctx);
EVP_EncryptInit_ex(m_ctx, EVP_rc4(), nullptr, nullptr, nullptr);
EVP_CIPHER_CTX_set_key_length(m_ctx, len);
}
ARC4::ARC4(uint8 *seed, uint32 len) : m_ctx()
ARC4::ARC4(uint8* seed, uint32 len) : m_ctx(EVP_CIPHER_CTX_new())
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
EVP_CIPHER_CTX_init(m_ctx);
EVP_EncryptInit_ex(m_ctx, EVP_rc4(), nullptr, nullptr, nullptr);
EVP_CIPHER_CTX_set_key_length(m_ctx, len);
EVP_EncryptInit_ex(m_ctx, nullptr, nullptr, seed, nullptr);
}
ARC4::~ARC4()
{
EVP_CIPHER_CTX_cleanup(&m_ctx);
EVP_CIPHER_CTX_free(m_ctx);
}
void ARC4::Init(uint8 *seed)
void ARC4::Init(uint8* seed)
{
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
EVP_EncryptInit_ex(m_ctx, nullptr, nullptr, seed, nullptr);
}
void ARC4::UpdateData(int len, uint8 *data)
void ARC4::UpdateData(int len, uint8* data)
{
int outlen = 0;
EVP_EncryptUpdate(&m_ctx, data, &outlen, data, len);
EVP_EncryptFinal_ex(&m_ctx, data, &outlen);
EVP_EncryptUpdate(m_ctx, data, &outlen, data, len);
EVP_EncryptFinal_ex(m_ctx, data, &outlen);
}