#include "AES.h"
◆ IV
◆ Key
◆ Tag
◆ AES()
Acore::Crypto::AES::AES |
( |
bool |
encrypting | ) |
|
|
explicit |
23{
24 EVP_CIPHER_CTX_init(
_ctx);
25 int status = EVP_CipherInit_ex(
_ctx, EVP_aes_128_gcm(),
nullptr,
nullptr,
nullptr,
_encrypting ? 1 : 0);
27}
#define ASSERT
Definition Errors.h:68
bool _encrypting
Definition AES.h:47
EVP_CIPHER_CTX * _ctx
Definition AES.h:46
References _ctx, _encrypting, and ASSERT.
◆ ~AES()
Acore::Crypto::AES::~AES |
( |
| ) |
|
30{
31 EVP_CIPHER_CTX_free(
_ctx);
32}
◆ Init()
void Acore::Crypto::AES::Init |
( |
Key const & |
key | ) |
|
35{
36 int status = EVP_CipherInit_ex(
_ctx,
nullptr,
nullptr, key.data(),
nullptr, -1);
38}
References ASSERT.
◆ Process()
bool Acore::Crypto::AES::Process |
( |
IV const & |
iv, |
|
|
uint8 * |
data, |
|
|
std::size_t |
length, |
|
|
Tag & |
tag |
|
) |
| |
41{
42 ASSERT(length <=
static_cast<size_t>(std::numeric_limits<int>::max()));
43 int len = static_cast<int>(length);
44 if (!EVP_CipherInit_ex(
_ctx,
nullptr,
nullptr,
nullptr, iv.data(), -1))
45 return false;
46
47 int outLen;
48 if (!EVP_CipherUpdate(
_ctx, data, &outLen, data, len))
49 return false;
50
51 len -= outLen;
52
53 if (!
_encrypting && !EVP_CIPHER_CTX_ctrl(
_ctx, EVP_CTRL_GCM_SET_TAG,
sizeof(tag), tag))
54 return false;
55
56 if (!EVP_CipherFinal_ex(
_ctx, data + outLen, &outLen))
57 return false;
58
60
61 if (
_encrypting && !EVP_CIPHER_CTX_ctrl(
_ctx, EVP_CTRL_GCM_GET_TAG,
sizeof(tag), tag))
62 return false;
63
64 return true;
65}
References ASSERT.
◆ _ctx
EVP_CIPHER_CTX* Acore::Crypto::AES::_ctx |
|
private |
◆ _encrypting
bool Acore::Crypto::AES::_encrypting |
|
private |
◆ IV_SIZE_BYTES
constexpr std::size_t Acore::Crypto::AES::IV_SIZE_BYTES = 12 |
|
staticconstexpr |
◆ KEY_SIZE_BYTES
constexpr std::size_t Acore::Crypto::AES::KEY_SIZE_BYTES = 16 |
|
staticconstexpr |
◆ TAG_SIZE_BYTES
constexpr std::size_t Acore::Crypto::AES::TAG_SIZE_BYTES = 12 |
|
staticconstexpr |
The documentation for this class was generated from the following files:
- azerothcore-wotlk/src/common/Cryptography/AES.h
- azerothcore-wotlk/src/common/Cryptography/AES.cpp