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