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