Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
SessionKeyGenerator.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#include <cstring>
7
#include "
CryptoHash.h
"
8
9
#ifndef _SESSIONKEYGENERATOR_HPP
10
#define _SESSIONKEYGENERATOR_HPP
11
12
template
<
typename
Hash>
13
class
SessionKeyGenerator
14
{
15
public
:
16
template
<
typename
C>
17
SessionKeyGenerator
(C
const
& buf) :
18
o0it
(
o0
.begin())
19
{
20
uint8
const
* data = std::data(buf);
21
size_t
const
len = std::size(buf);
22
size_t
const
halflen = (len / 2);
23
24
o1
= Hash::GetDigestOf(data, halflen);
25
o2
= Hash::GetDigestOf(data + halflen, len - halflen);
26
o0
= Hash::GetDigestOf(
o1
,
o0
,
o2
);
27
}
28
29
void
Generate
(
uint8
* buf,
uint32
sz)
30
{
31
for
(
uint32
i = 0; i < sz; ++i)
32
{
33
if
(
o0it
==
o0
.end())
34
{
35
o0
= Hash::GetDigestOf(
o1
,
o0
,
o2
);
36
o0it
=
o0
.begin();
37
}
38
39
buf[i] = *(
o0it
++);
40
}
41
}
42
43
private
:
44
typename
Hash::Digest
o0
= { };
45
typename
Hash::Digest
o1
= { };
46
typename
Hash::Digest
o2
= { };
47
typename
Hash::Digest::const_iterator
o0it
;
48
};
49
50
#endif
CryptoHash.h
uint8
std::uint8_t uint8
Definition
Define.h:79
uint32
std::uint32_t uint32
Definition
Define.h:77
SessionKeyGenerator::o0
Hash::Digest o0
Definition
SessionKeyGenerator.h:44
SessionKeyGenerator::Generate
void Generate(uint8 *buf, uint32 sz)
Definition
SessionKeyGenerator.h:29
SessionKeyGenerator::o1
Hash::Digest o1
Definition
SessionKeyGenerator.h:45
SessionKeyGenerator::o2
Hash::Digest o2
Definition
SessionKeyGenerator.h:46
SessionKeyGenerator::o0it
Hash::Digest::const_iterator o0it
Definition
SessionKeyGenerator.h:47
SessionKeyGenerator::SessionKeyGenerator
SessionKeyGenerator(C const &buf)
Definition
SessionKeyGenerator.h:17
src
server
shared
Cryptography
SessionKeyGenerator.h
Generated on
for Project SkyFire Core by
1.17.0