BigDigits  2.6.1
Functions
bigdRand.h File Reference

Interface for BigDigits "bd" random number functions using a "pretty-good" internal RNG. More...

Functions

bdigit_t bdRandDigit (void)
 Generate a single random digit using internal RNG. More...
 
size_t bdRandomBits (BIGD a, size_t nbits)
 Generate a random BIGD number of bit length at most nbits using internal RNG. More...
 
size_t bdRandomNumber (BIGD a, BIGD n)
 Generate a number at random from a uniform distribution in [0, n-1]. More...
 
int bdRandomOctets (unsigned char *bytes, size_t nbytes, const unsigned char *seed, size_t seedlen)
 Generate array of random octets (bytes) using internal RNG. More...
 

Detailed Description

Interface for BigDigits "bd" random number functions using a "pretty-good" internal RNG.

The internal random number generator (RNG)
The internal RNG uses a variant of the random number generation algorithm in Appendix A of ANSI X9.31-1998, but using the Tiny Encryption Algorithm (TEAX) instead of the Data Encryption Algorithm (DEA). It uses the current time and process ID as a seed. Although not strictly crypto secure, it is "pretty good", and certainly much better than anything using the built-in rand() function in C. Look at the source code and make your own call.
If you want proper cryptographic security, use the bdRandomSeeded() function with a call to a secure RNG function that you trust.

Function Documentation

bdigit_t bdRandDigit ( void  )

Generate a single random digit using internal RNG.

size_t bdRandomBits ( BIGD  a,
size_t  nbits 
)

Generate a random BIGD number of bit length at most nbits using internal RNG.

Parameters
[out]ato receive generated random number
[in]nbitsmaximum number of bits
Returns
Number of digits actually set
size_t bdRandomNumber ( BIGD  a,
BIGD  n 
)

Generate a number at random from a uniform distribution in [0, n-1].

int bdRandomOctets ( unsigned char *  bytes,
size_t  nbytes,
const unsigned char *  seed,
size_t  seedlen 
)

Generate array of random octets (bytes) using internal RNG.

Remarks
This function is in the correct form for BD_RANDFUNC.
Copyright © 2001-16 D.I. Management Services Pty Limited ABN 78 083 210 584 Australia. All rights reserved. <www.di-mgt.com.au/bigdigits.html> Generated on Sat Dec 8 2018 10:38:43 by Doxygen 1.8.3.1.