forked from wwivbbs/wwiv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosek.c
58 lines (45 loc) · 1.72 KB
/
osek.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/****************************************************************************
* *
* OSEK Randomness-Gathering Code *
* Copyright Peter Gutmann 1996-2005 *
* *
****************************************************************************/
/* This module is part of the cryptlib continuously seeded pseudorandom
number generator. For usage conditions, see random.c.
This code represents a template for randomness-gathering only and will
need to be modified to provide randomness via an external source. In its
current form it does not provide any usable entropy and should not be
used as an entropy source */
/* General includes */
#include <os.h>
#include "crypt.h"
#include "random/random.h"
/* The size of the intermediate buffer used to accumulate polled data */
#define RANDOM_BUFSIZE 256
void fastPoll( void )
{
RANDOM_STATE randomState;
BYTE buffer[ RANDOM_BUFSIZE ];
/* Get the core that we're currently running on */
initRandomData( randomState, buffer, RANDOM_BUFSIZE );
addRandomValue( randomState, GetCoreID() );
endRandomData( randomState, 1 );
}
void slowPoll( void )
{
RANDOM_STATE randomState;
BYTE buffer[ RANDOM_BUFSIZE ];
static BOOLEAN addedStaticData = FALSE;
initRandomData( randomState, buffer, RANDOM_BUFSIZE );
/* Get static system information */
if( !addedStaticData )
{
/* The application ID is fixed at compile time, the current
application ID is almost always the same thing */
addRandomValue( randomState, GetApplicationID() );
addRandomValue( randomState, GetCurrentApplicationID() );
addRandomValue( randomState, GetNumberOfActivatedCores() );
addedStaticData = TRUE;
}
endRandomData( randomState, 1 );
}