manpagez: man pages & more
info gmp
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2 Random State Seeding

Function: void gmp_randseed (gmp_randstate_t state, mpz_t seed)
Function: void gmp_randseed_ui (gmp_randstate_t state, unsigned long int seed)

Set an initial seed value into state.

The size of a seed determines how many different sequences of random numbers that it’s possible to generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed used, and this affects the randomness of separate number sequences. The method for choosing a seed is critical if the generated numbers are to be used for important applications, such as generating cryptographic keys.

Traditionally the system time has been used to seed, but care needs to be taken with this. If an application seeds often and the resolution of the system clock is low, then the same sequence of numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is required then it should definitely not be the only source for the seed value. On some systems there’s a special device ‘/dev/random’ which provides random data better suited for use as a seed.

This document was generated on February 16, 2012 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.