1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License as published by |
---|
6 | * the Free Software Foundation; either version 2 of the License, or |
---|
7 | * (at your option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this program; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _AUTHCRYPT_H |
---|
20 | #define _AUTHCRYPT_H |
---|
21 | |
---|
22 | #include <Common.h> |
---|
23 | #include <vector> |
---|
24 | |
---|
25 | class BigNumber; |
---|
26 | |
---|
27 | class AuthCrypt |
---|
28 | { |
---|
29 | public: |
---|
30 | AuthCrypt(); |
---|
31 | ~AuthCrypt(); |
---|
32 | |
---|
33 | const static size_t CRYPTED_SEND_LEN = 4; |
---|
34 | const static size_t CRYPTED_RECV_LEN = 6; |
---|
35 | |
---|
36 | void Init(); |
---|
37 | |
---|
38 | void SetKey(BigNumber *); |
---|
39 | |
---|
40 | void DecryptRecv(uint8 *, size_t); |
---|
41 | void EncryptSend(uint8 *, size_t); |
---|
42 | |
---|
43 | bool IsInitialized() { return _initialized; } |
---|
44 | |
---|
45 | static void GenerateKey(uint8 *, BigNumber *); |
---|
46 | |
---|
47 | private: |
---|
48 | std::vector<uint8> _key; |
---|
49 | uint8 _send_i, _send_j, _recv_i, _recv_j; |
---|
50 | bool _initialized; |
---|
51 | }; |
---|
52 | #endif |
---|