TrinityCore
Loading...
Searching...
No Matches
SessionKeyGenerator.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_SESSIONKEYGENERATOR_HPP
19
#define TRINITY_SESSIONKEYGENERATOR_HPP
20
21
#include "
CryptoHash.h
"
22
23
template
<
typename
Hash>
24
class
SessionKeyGenerator
25
{
26
public
:
27
template
<
typename
C>
28
SessionKeyGenerator
(C
const
& buf) :
29
o0it
(
o0
.begin())
30
{
31
uint8
const
* data = std::data(buf);
32
size_t
const
len = std::size(buf);
33
size_t
const
halflen = (len / 2);
34
35
o1
= Hash::GetDigestOf(data, halflen);
36
o2
= Hash::GetDigestOf(data + halflen, len - halflen);
37
o0
= Hash::GetDigestOf(
o1
,
o0
,
o2
);
38
}
39
40
void
Generate
(
uint8
* buf,
uint32
sz)
41
{
42
for
(
uint32
i = 0; i < sz; ++i)
43
{
44
if
(
o0it
==
o0
.end())
45
{
46
o0
= Hash::GetDigestOf(
o1
,
o0
,
o2
);
47
o0it
=
o0
.begin();
48
}
49
50
buf[i] = *(
o0it
++);
51
}
52
}
53
54
private
:
55
typename
Hash::Digest
o0
= { };
56
typename
Hash::Digest
o1
= { };
57
typename
Hash::Digest
o2
= { };
58
typename
Hash::Digest::const_iterator
o0it
;
59
};
60
61
#endif
CryptoHash.h
uint8
uint8_t uint8
Definition
Define.h:156
uint32
uint32_t uint32
Definition
Define.h:154
SessionKeyGenerator
Definition
SessionKeyGenerator.h:25
SessionKeyGenerator::o0
Hash::Digest o0
Definition
SessionKeyGenerator.h:55
SessionKeyGenerator::Generate
void Generate(uint8 *buf, uint32 sz)
Definition
SessionKeyGenerator.h:40
SessionKeyGenerator::o1
Hash::Digest o1
Definition
SessionKeyGenerator.h:56
SessionKeyGenerator::o2
Hash::Digest o2
Definition
SessionKeyGenerator.h:57
SessionKeyGenerator::o0it
Hash::Digest::const_iterator o0it
Definition
SessionKeyGenerator.h:58
SessionKeyGenerator::SessionKeyGenerator
SessionKeyGenerator(C const &buf)
Definition
SessionKeyGenerator.h:28
common
Cryptography
SessionKeyGenerator.h
Generated on Sun May 10 2026 02:08:51 for TrinityCore by
1.9.8