Richard Boegli's CnC_Generals_Zero_Hour Fork
WIP
This is documentation of Richard Boegil's Zero Hour Fork
Loading...
Searching...
No Matches
srandom.h
Go to the documentation of this file.
1
/*
2
** Command & Conquer Generals Zero Hour(tm)
3
** Copyright 2025 Electronic Arts Inc.
4
**
5
** This program is free software: you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation, either version 3 of the License, or
8
** (at your option) any later version.
9
**
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
14
**
15
** You should have received a copy of the GNU General Public License
16
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef SRANDOM_H
20
#define SRANDOM_H
21
22
#include "
random.h
"
// for the helper RNG
23
24
//
25
// SecureRandomClass - Generate random values that are suitable for use in cryptographic
26
// applications (under UNIX at least).
27
//
28
// NOTE: The seed generation under windows isn't nearly as strong as under UNIX due to
29
// the lack of /dev/random. If you have a good random source you can call 'Add_Seeds'
30
// to improve the quality of the seed value.
31
//
32
// Currently the random seed generation under windows is piss-poor so make sure and call
33
// Add_Seeds with some interesting data if you're going to use this!
34
//
35
// The seed values should be unguessable by an outside viewer and the random values have
36
// good distribution properties.
37
//
38
class
SecureRandomClass
39
{
40
public
:
41
SecureRandomClass
();
42
~SecureRandomClass
();
43
44
unsigned
long
Randval
();
// get a 32 bit random value
45
46
// Add randomness to the seed pool
47
void
Add_Seeds
(
unsigned
char
*values,
int
length);
48
49
private
:
50
void
Generate_Seed(
void
);
// Generate the inital seed
51
52
enum
53
{
54
SeedLength = 16,
// bytes in random seed
55
SHADigestBytes = 20
// length of SHA hash
56
};
57
58
static
bool
Initialized;
// has the seed been initialized?
59
static
unsigned
char
Seeds[SeedLength];
// random seed values
60
static
unsigned
int
RandomCache[SHADigestBytes /
sizeof
(
unsigned
int)];
61
static
int
RandomCacheEntries;
62
static
unsigned
int
Counter;
63
64
static
Random3Class
RandomHelper;
65
};
66
67
#endif
RANDOM.H
Random3Class
Definition
RANDOM.H:135
SecureRandomClass::SecureRandomClass
SecureRandomClass()
Definition
srandom.cpp:54
SecureRandomClass::Add_Seeds
void Add_Seeds(unsigned char *values, int length)
Definition
srandom.cpp:71
SecureRandomClass::Randval
unsigned long Randval()
Definition
srandom.cpp:91
SecureRandomClass::~SecureRandomClass
~SecureRandomClass()
Definition
srandom.cpp:63
Code
Libraries
Source
WWVegas
WWLib
srandom.h
Generated by
1.13.2