TrinityCore
Loading...
Searching...
No Matches
AES.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef Trinity_AES_h__
19#define Trinity_AES_h__
20
21#include "Define.h"
22#include <array>
23#include <span>
24#include <openssl/evp.h>
25
27{
29 {
30 public:
31 static constexpr size_t IV_SIZE_BYTES = 12;
32 static constexpr size_t KEY_SIZE_BYTES = 16;
33 static constexpr size_t TAG_SIZE_BYTES = 12;
34
35 using IV = std::array<uint8, IV_SIZE_BYTES>;
36 using Key = std::array<uint8, KEY_SIZE_BYTES>;
37 using Tag = uint8[TAG_SIZE_BYTES];
38
39 AES(bool encrypting, size_t keySizeBits = 128);
40 AES(AES const&) = delete;
41 AES(AES&&) = delete;
42 AES& operator=(AES const&) = delete;
43 AES& operator=(AES&&) = delete;
44 ~AES();
45
46 void Init(Key const& key);
47 void Init(std::span<uint8 const> key);
48
49 bool Process(IV const& iv, uint8* data, size_t length, Tag& tag);
50 bool ProcessNoIntegrityCheck(IV const& iv, uint8* data, size_t partialLength);
51
52 private:
53 EVP_CIPHER_CTX* _ctx;
55 };
56}
57
58#endif // Trinity_AES_h__
uint8_t uint8
Definition Define.h:156
#define TC_COMMON_API
Definition Define.h:99
uint8[TAG_SIZE_BYTES] Tag
Definition AES.h:37
AES & operator=(AES &&)=delete
std::array< uint8, IV_SIZE_BYTES > IV
Definition AES.h:35
AES(AES const &)=delete
AES & operator=(AES const &)=delete
std::array< uint8, KEY_SIZE_BYTES > Key
Definition AES.h:36
AES(AES &&)=delete
EVP_CIPHER_CTX * _ctx
Definition AES.h:53