michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _SECRNG_H_ michael@0: #define _SECRNG_H_ michael@0: /* michael@0: * secrng.h - public data structures and prototypes for the secure random michael@0: * number generator michael@0: */ michael@0: michael@0: /******************************************/ michael@0: /* michael@0: ** Random number generation. A cryptographically strong random number michael@0: ** generator. michael@0: */ michael@0: michael@0: #include "blapi.h" michael@0: michael@0: /* the number of bytes to read from the system random number generator */ michael@0: #define SYSTEM_RNG_SEED_COUNT 1024 michael@0: michael@0: SEC_BEGIN_PROTOS michael@0: michael@0: /* michael@0: ** The following functions are provided by the security library michael@0: ** but are differently implemented for the UNIX, Win, and OS/2 michael@0: ** versions michael@0: */ michael@0: michael@0: /* michael@0: ** Get the "noisiest" information available on the system. michael@0: ** The amount of data returned depends on the system implementation. michael@0: ** It will not exceed maxbytes, but may be (much) less. michael@0: ** Returns number of noise bytes copied into buf, or zero if error. michael@0: */ michael@0: extern size_t RNG_GetNoise(void *buf, size_t maxbytes); michael@0: michael@0: /* michael@0: ** RNG_SystemInfoForRNG should be called before any use of SSL. It michael@0: ** gathers up the system specific information to help seed the michael@0: ** state of the global random number generator. michael@0: */ michael@0: extern void RNG_SystemInfoForRNG(void); michael@0: michael@0: /* michael@0: ** Use the contents (and stat) of a file to help seed the michael@0: ** global random number generator. michael@0: */ michael@0: extern void RNG_FileForRNG(const char *filename); michael@0: michael@0: /* michael@0: ** Get maxbytes bytes of random data from the system random number michael@0: ** generator. michael@0: ** Returns the number of bytes copied into buf -- maxbytes if success michael@0: ** or zero if error. michael@0: ** Errors: michael@0: ** PR_NOT_IMPLEMENTED_ERROR There is no system RNG on the platform. michael@0: ** SEC_ERROR_NEED_RANDOM The system RNG failed. michael@0: */ michael@0: extern size_t RNG_SystemRNG(void *buf, size_t maxbytes); michael@0: michael@0: SEC_END_PROTOS michael@0: michael@0: #endif /* _SECRNG_H_ */