Legends-of-Azeroth-Pandaria-5.4.8

Форк
0
52 строки · 1.7 Кб
1
/*
2
* This file is part of the Pandaria 5.4.8 Project. See THANKS 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 <cstring>
19
#include "AuthCrypt.h"
20
#include "Cryptography/BigNumber.h"
21
#include "Cryptography/HMAC.h"
22

23
AuthCrypt::AuthCrypt() :
24
    _initialized(false)
25
{ }
26

27
void AuthCrypt::Init(SessionKey const& K)
28
{
29
    uint8 ServerEncryptionKey[] = { 0x08, 0xF1, 0x95, 0x9F, 0x47, 0xE5, 0xD2, 0xDB, 0xA1, 0x3D, 0x77, 0x8F, 0x3F, 0x3E, 0xE7, 0x00 };
30
    _serverEncrypt.Init(Trinity::Crypto::HMAC_SHA1::GetDigestOf(ServerEncryptionKey, K));
31

32
    uint8 ServerDecryptionKey[] = { 0x40, 0xAA, 0xD3, 0x92, 0x26, 0x71, 0x43, 0x47, 0x3A, 0x31, 0x08, 0xA6, 0xE7, 0xDC, 0x98, 0x2A };
33
    _clientDecrypt.Init(Trinity::Crypto::HMAC_SHA1::GetDigestOf(ServerDecryptionKey, K));
34

35
    std::array<uint8, 1024> syncBuf;
36
    _serverEncrypt.UpdateData(syncBuf);
37
    _clientDecrypt.UpdateData(syncBuf);
38

39
    _initialized = true;
40
}
41

42
void AuthCrypt::DecryptRecv(uint8 *data, size_t len)
43
{
44
    ASSERT(_initialized);
45
    _clientDecrypt.UpdateData(data, len);
46
}
47

48
void AuthCrypt::EncryptSend(uint8 *data, size_t len)
49
{
50
    ASSERT(_initialized);
51
    _serverEncrypt.UpdateData(data, len);
52
}
53

54

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.