diff options
Diffstat (limited to 'src/common/Cryptography/AES.h')
-rw-r--r-- | src/common/Cryptography/AES.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/common/Cryptography/AES.h b/src/common/Cryptography/AES.h index 8f83b2e3e57..d3b9f48c552 100644 --- a/src/common/Cryptography/AES.h +++ b/src/common/Cryptography/AES.h @@ -19,26 +19,35 @@ #define Trinity_AES_h__ #include "Define.h" +#include <array> #include <openssl/evp.h> namespace Trinity { namespace Crypto { -class TC_COMMON_API AES -{ -public: - AES(bool encrypting); - ~AES(); + class TC_COMMON_API AES + { + public: + static constexpr size_t IV_SIZE_BYTES = 12; + static constexpr size_t KEY_SIZE_BYTES = 16; + static constexpr size_t TAG_SIZE_BYTES = 12; + + using IV = std::array<uint8, IV_SIZE_BYTES>; + using Key = std::array<uint8, KEY_SIZE_BYTES>; + using Tag = uint8[TAG_SIZE_BYTES]; + + AES(bool encrypting); + ~AES(); - void Init(uint8 const* key); + void Init(Key const& key); - bool Process(uint8 const* iv, uint8* data, std::size_t length, uint8(&tag)[12]); + bool Process(IV const& iv, uint8* data, size_t length, Tag& tag); -private: - EVP_CIPHER_CTX* _ctx; - bool _encrypting; -}; + private: + EVP_CIPHER_CTX* _ctx; + bool _encrypting; + }; } } |