1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/freebl/secrng.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef _SECRNG_H_ 1.9 +#define _SECRNG_H_ 1.10 +/* 1.11 + * secrng.h - public data structures and prototypes for the secure random 1.12 + * number generator 1.13 + */ 1.14 + 1.15 +/******************************************/ 1.16 +/* 1.17 +** Random number generation. A cryptographically strong random number 1.18 +** generator. 1.19 +*/ 1.20 + 1.21 +#include "blapi.h" 1.22 + 1.23 +/* the number of bytes to read from the system random number generator */ 1.24 +#define SYSTEM_RNG_SEED_COUNT 1024 1.25 + 1.26 +SEC_BEGIN_PROTOS 1.27 + 1.28 +/* 1.29 +** The following functions are provided by the security library 1.30 +** but are differently implemented for the UNIX, Win, and OS/2 1.31 +** versions 1.32 +*/ 1.33 + 1.34 +/* 1.35 +** Get the "noisiest" information available on the system. 1.36 +** The amount of data returned depends on the system implementation. 1.37 +** It will not exceed maxbytes, but may be (much) less. 1.38 +** Returns number of noise bytes copied into buf, or zero if error. 1.39 +*/ 1.40 +extern size_t RNG_GetNoise(void *buf, size_t maxbytes); 1.41 + 1.42 +/* 1.43 +** RNG_SystemInfoForRNG should be called before any use of SSL. It 1.44 +** gathers up the system specific information to help seed the 1.45 +** state of the global random number generator. 1.46 +*/ 1.47 +extern void RNG_SystemInfoForRNG(void); 1.48 + 1.49 +/* 1.50 +** Use the contents (and stat) of a file to help seed the 1.51 +** global random number generator. 1.52 +*/ 1.53 +extern void RNG_FileForRNG(const char *filename); 1.54 + 1.55 +/* 1.56 +** Get maxbytes bytes of random data from the system random number 1.57 +** generator. 1.58 +** Returns the number of bytes copied into buf -- maxbytes if success 1.59 +** or zero if error. 1.60 +** Errors: 1.61 +** PR_NOT_IMPLEMENTED_ERROR There is no system RNG on the platform. 1.62 +** SEC_ERROR_NEED_RANDOM The system RNG failed. 1.63 +*/ 1.64 +extern size_t RNG_SystemRNG(void *buf, size_t maxbytes); 1.65 + 1.66 +SEC_END_PROTOS 1.67 + 1.68 +#endif /* _SECRNG_H_ */