Core/Crypto: Transitional Cryptography update for OpenSSL 1.1
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: cmangos/mangos-wotlk@e1b0048
This commit is contained in:
parent
783003f0e8
commit
53364abcd7
4 changed files with 48 additions and 32 deletions
|
|
@ -7,34 +7,34 @@
|
|||
#include "ARC4.h"
|
||||
#include <openssl/sha.h>
|
||||
|
||||
ARC4::ARC4(uint8 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, uint8 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue