TrinityCore
Loading...
Searching...
No Matches
WorldPacketCrypt.cpp
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#include "WorldPacketCrypt.h"
19#include "Errors.h"
20#include "HMAC.h"
21
23{
24}
25
27{
28 static constexpr std::array<uint8, 16> ServerEncryptionKey = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
29 static constexpr std::array<uint8, 16> ServerDecryptionKey = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
30
31 Init(K, ServerEncryptionKey, ServerDecryptionKey);
32}
33
34void WorldPacketCrypt::Init(SessionKey const& K, std::span<uint8 const, 16> serverKey, std::span<uint8 const, 16> clientKey)
35{
38
39 // Drop first 1024 bytes, as WoW uses ARC4-drop1024.
40 std::array<uint8, 1024> syncBuf;
43
44 _initialized = true;
45}
46
47void WorldPacketCrypt::DecryptRecv(uint8 *data, size_t len)
48{
50 _clientDecrypt.UpdateData(data, len);
51}
52
53void WorldPacketCrypt::EncryptSend(uint8 *data, size_t len)
54{
56 _serverEncrypt.UpdateData(data, len);
57}
std::array< uint8, SESSION_KEY_LENGTH > SessionKey
Definition AuthDefines.h:25
uint8_t uint8
Definition Define.h:135
#define ASSERT
Definition Errors.h:68
void UpdateData(uint8 *data, size_t len)
Definition ARC4.cpp:51
void Init(uint8 const *seed, size_t len)
Definition ARC4.cpp:43
static Digest GetDigestOf(Container const &seed, uint8 const *data, size_t len)
Definition HMAC.h:41
Trinity::Crypto::ARC4 _clientDecrypt
Trinity::Crypto::ARC4 _serverEncrypt
void EncryptSend(uint8 *data, size_t len)
void Init(SessionKey const &K)
void DecryptRecv(uint8 *data, size_t len)