tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

secrng.h (1886B)


      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 
     12 /******************************************/
     13 /*
     14 ** Random number generation. A cryptographically strong random number
     15 ** generator.
     16 */
     17 
     18 #include "blapi.h"
     19 
     20 /* the number of bytes to read from the system random number generator */
     21 #define SYSTEM_RNG_SEED_COUNT 1024
     22 
     23 SEC_BEGIN_PROTOS
     24 
     25 /*
     26 ** The following functions are provided by the security library
     27 ** but are differently implemented for the UNIX, Win, and OS/2
     28 ** versions
     29 */
     30 
     31 /*
     32 ** Get the "noisiest" information available on the system.
     33 ** The amount of data returned depends on the system implementation.
     34 ** It will not exceed maxbytes, but may be (much) less.
     35 ** Returns number of noise bytes copied into buf, or zero if error.
     36 */
     37 extern size_t RNG_GetNoise(void *buf, size_t maxbytes);
     38 
     39 /*
     40 ** RNG_SystemInfoForRNG should be called before any use of SSL. It
     41 ** gathers up the system specific information to help seed the
     42 ** state of the global random number generator.
     43 */
     44 extern void RNG_SystemInfoForRNG(void);
     45 
     46 /*
     47 ** Use the contents (and stat) of a file to help seed the
     48 ** global random number generator.
     49 */
     50 extern void RNG_FileForRNG(const char *filename);
     51 
     52 /*
     53 ** Get maxbytes bytes of random data from the system random number
     54 ** generator.
     55 ** Returns the number of bytes copied into buf -- maxbytes if success
     56 ** or zero if error.
     57 ** Errors:
     58 **   PR_NOT_IMPLEMENTED_ERROR   There is no system RNG on the platform.
     59 **   SEC_ERROR_NEED_RANDOM      The system RNG failed.
     60 */
     61 extern size_t RNG_SystemRNG(void *buf, size_t maxbytes);
     62 
     63 SEC_END_PROTOS
     64 
     65 #endif /* _SECRNG_H_ */