AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Crypto::ARC4 Class Reference

#include "ARC4.h"

Public Member Functions

 ARC4 ()
 
 ~ARC4 ()
 
void Init (uint8 const *seed, std::size_t len)
 
template<typename Container >
void Init (Container const &c)
 
void UpdateData (uint8 *data, std::size_t len)
 
template<typename Container >
void UpdateData (Container &c)
 

Private Attributes

EVP_CIPHER * _cipher
 
EVP_CIPHER_CTX * _ctx
 

Detailed Description

Constructor & Destructor Documentation

◆ ARC4()

Acore::Crypto::ARC4::ARC4 ( )
21 : _ctx(EVP_CIPHER_CTX_new())
22{
23 _cipher = EVP_CIPHER_fetch(nullptr, "RC4", nullptr);
24
25 EVP_CIPHER_CTX_init(_ctx);
26 int result = EVP_EncryptInit_ex(_ctx, _cipher, nullptr, nullptr, nullptr);
27 ASSERT(result == 1);
28}
#define ASSERT
Definition: Errors.h:68
EVP_CIPHER_CTX * _ctx
Definition: ARC4.h:44
EVP_CIPHER * _cipher
Definition: ARC4.h:43

References _cipher, _ctx, and ASSERT.

◆ ~ARC4()

Acore::Crypto::ARC4::~ARC4 ( )
31{
32 EVP_CIPHER_CTX_free(_ctx);
33 EVP_CIPHER_free(_cipher);
34}

Member Function Documentation

◆ Init() [1/2]

template<typename Container >
void Acore::Crypto::ARC4::Init ( Container const &  c)
inline
36{ Init(std::data(c), std::size(c)); }
void Init(uint8 const *seed, std::size_t len)
Definition: ARC4.cpp:36

References Init().

Referenced by Init().

◆ Init() [2/2]

void Acore::Crypto::ARC4::Init ( uint8 const *  seed,
std::size_t  len 
)
37{
38 int result1 = EVP_CIPHER_CTX_set_key_length(_ctx, len);
39 ASSERT(result1 == 1);
40 int result2 = EVP_EncryptInit_ex(_ctx, nullptr, nullptr, seed, nullptr);
41 ASSERT(result2 == 1);
42}

References ASSERT.

Referenced by WardenMac::HandleHashResult(), WardenWin::HandleHashResult(), AuthCrypt::Init(), WardenMac::Init(), and WardenWin::Init().

◆ UpdateData() [1/2]

template<typename Container >
void Acore::Crypto::ARC4::UpdateData ( Container c)
inline
41{ UpdateData(std::data(c), std::size(c)); }
Definition: UpdateData.h:52

References UpdateData().

Referenced by UpdateData().

◆ UpdateData() [2/2]

void Acore::Crypto::ARC4::UpdateData ( uint8 data,
std::size_t  len 
)
45{
46 int outlen = 0;
47 int result1 = EVP_EncryptUpdate(_ctx, data, &outlen, data, len);
48 ASSERT(result1 == 1);
49 int result2 = EVP_EncryptFinal_ex(_ctx, data, &outlen);
50 ASSERT(result2 == 1);
51}

References ASSERT.

Referenced by Warden::DecryptData(), AuthCrypt::DecryptRecv(), Warden::EncryptData(), AuthCrypt::EncryptSend(), and AuthCrypt::Init().

Member Data Documentation

◆ _cipher

EVP_CIPHER* Acore::Crypto::ARC4::_cipher
private

Referenced by ARC4().

◆ _ctx

EVP_CIPHER_CTX* Acore::Crypto::ARC4::_ctx
private

Referenced by ARC4().