cryptlib
3.4.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
random
chorus.c
Go to the documentation of this file.
1
/****************************************************************************
2
* *
3
* ChorusOS Randomness-Gathering Code *
4
* Copyright Peter Gutmann 1996-2005 *
5
* *
6
****************************************************************************/
7
8
/* This module is part of the cryptlib continuously seeded pseudorandom
9
number generator. For usage conditions, see random.c.
10
11
This code represents a template for randomness-gathering only and will
12
need to be modified to provide randomness via an external source. In its
13
current form it does not provide any usable entropy and should not be
14
used as an entropy source */
15
16
/* General includes */
17
18
#include <chorus.h>
19
#include <afexec.h>
20
#include <exec/chTime.h>
21
#include "
crypt.h
"
22
23
/* The size of the intermediate buffer used to accumulate polled data */
24
25
#define RANDOM_BUFSIZE 256
26
27
void
fastPoll
(
void
)
28
{
29
RANDOM_STATE
randomState;
30
BYTE
buffer
[
RANDOM_BUFSIZE
];
31
KnTimeVal
timeVal
;
32
33
/* The sysTime() ns timer seems to be quantised to ms rather than
34
being true ns timer output. Other (supposedly) high-speed timers
35
like sysBench() are no better, on x86 hardware this is quantised
36
to 5ms intervals */
37
initRandomData( randomState, buffer,
RANDOM_BUFSIZE
);
38
sysTime( &timeVal );
39
addRandomData( randomState, &timeVal,
sizeof
( KnTimeVal ) );
40
endRandomData( randomState, 1 );
41
}
42
43
void
slowPoll
(
void
)
44
{
45
RANDOM_STATE
randomState;
46
BYTE
buffer
[
RANDOM_BUFSIZE
];
47
48
initRandomData( randomState, buffer,
RANDOM_BUFSIZE
);
49
addRandomValue
( randomState, agetId() );
50
endRandomData( randomState, 1 );
51
52
/* ChorusOS provides the MkStat family of calls (equivalent to Sun's
53
kstats), but these can only be called in supervisor mode */
54
return
;
55
}
Generated on Thu Jan 10 2013 10:00:51 for cryptlib by
1.8.2