OLD | NEW |
| (Empty) |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 | |
5 #ifndef _SECRNG_H_ | |
6 #define _SECRNG_H_ | |
7 /* | |
8 * secrng.h - public data structures and prototypes for the secure random | |
9 * number generator | |
10 * | |
11 * $Id: secrng.h,v 1.7 2012/04/25 14:49:43 gerv%gerv.net Exp $ | |
12 */ | |
13 | |
14 /******************************************/ | |
15 /* | |
16 ** Random number generation. A cryptographically strong random number | |
17 ** generator. | |
18 */ | |
19 | |
20 #include "blapi.h" | |
21 | |
22 /* the number of bytes to read from the system random number generator */ | |
23 #define SYSTEM_RNG_SEED_COUNT 1024 | |
24 | |
25 SEC_BEGIN_PROTOS | |
26 | |
27 /* | |
28 ** The following functions are provided by the security library | |
29 ** but are differently implemented for the UNIX, Win, and OS/2 | |
30 ** versions | |
31 */ | |
32 | |
33 /* | |
34 ** Get the "noisiest" information available on the system. | |
35 ** The amount of data returned depends on the system implementation. | |
36 ** It will not exceed maxbytes, but may be (much) less. | |
37 ** Returns number of noise bytes copied into buf, or zero if error. | |
38 */ | |
39 extern size_t RNG_GetNoise(void *buf, size_t maxbytes); | |
40 | |
41 /* | |
42 ** RNG_SystemInfoForRNG should be called before any use of SSL. It | |
43 ** gathers up the system specific information to help seed the | |
44 ** state of the global random number generator. | |
45 */ | |
46 extern void RNG_SystemInfoForRNG(void); | |
47 | |
48 /* | |
49 ** Use the contents (and stat) of a file to help seed the | |
50 ** global random number generator. | |
51 */ | |
52 extern void RNG_FileForRNG(const char *filename); | |
53 | |
54 /* | |
55 ** Get maxbytes bytes of random data from the system random number | |
56 ** generator. | |
57 ** Returns the number of bytes copied into buf -- maxbytes if success | |
58 ** or zero if error. | |
59 ** Errors: | |
60 ** PR_NOT_IMPLEMENTED_ERROR There is no system RNG on the platform. | |
61 ** SEC_ERROR_NEED_RANDOM The system RNG failed. | |
62 */ | |
63 extern size_t RNG_SystemRNG(void *buf, size_t maxbytes); | |
64 | |
65 SEC_END_PROTOS | |
66 | |
67 #endif /* _SECRNG_H_ */ | |
OLD | NEW |