TrinityCore
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 <openssl/evp.h>
24
26{
28 {
29 public:
30 static constexpr size_t IV_SIZE_BYTES = 12;
31 static constexpr size_t KEY_SIZE_BYTES = 16;
32 static constexpr size_t TAG_SIZE_BYTES = 12;
33
34 using IV = std::array<uint8, IV_SIZE_BYTES>;
35 using Key = std::array<uint8, KEY_SIZE_BYTES>;
36 using Tag = uint8[TAG_SIZE_BYTES];
37
38 AES(bool encrypting);
39 ~AES();
40
41 void Init(Key const& key);
42
43 bool Process(IV const& iv, uint8* data, size_t length, Tag& tag);
44 bool ProcessNoIntegrityCheck(IV const& iv, uint8* data, size_t partialLength);
45
46 private:
47 EVP_CIPHER_CTX* _ctx;
49 };
50}
51
52#endif // Trinity_AES_h__
uint8_t uint8
Definition: Define.h:144
#define TC_COMMON_API
Definition: Define.h:99
uint8[TAG_SIZE_BYTES] Tag
Definition: AES.h:36
bool _encrypting
Definition: AES.h:48
std::array< uint8, IV_SIZE_BYTES > IV
Definition: AES.h:34
std::array< uint8, KEY_SIZE_BYTES > Key
Definition: AES.h:35
EVP_CIPHER_CTX * _ctx
Definition: AES.h:47
TC_COMMON_API void Init()
Definition: Locales.cpp:28