#include <stdlib.h>
#include <gpxe/timer.h>
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | srandom (unsigned int seed) |
| Seed the pseudo-random number generator. | |
| long int | random (void) |
| Generate a pseudo-random number between 0 and 2147483647L or 2147483562? | |
Variables | |
| static int32_t | rnd_seed = 0 |
Definition in file random.c.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void srandom | ( | unsigned int | seed | ) |
| long int random | ( | void | ) |
Generate a pseudo-random number between 0 and 2147483647L or 2147483562?
| rand | Pseudo-random number |
Definition at line 28 of file random.c.
References currticks(), rnd_seed, and srandom().
Referenced by forcedeth_reset(), get_random_bytes(), hermon_alloc_qpn(), ib_create_conn(), ib_create_qp(), iscsi_handle_chap_c_value(), rand(), tcp_open(), tls_new_server_hello(), tls_send_client_hello(), and wep_encrypt().
00028 { 00029 int32_t q; 00030 00031 if ( ! rnd_seed ) /* Initialize linear congruential generator */ 00032 srandom ( currticks() ); 00033 00034 /* simplified version of the LCG given in Bruce Schneier's 00035 "Applied Cryptography" */ 00036 q = ( rnd_seed / 53668 ); 00037 rnd_seed = ( 40014 * ( rnd_seed - 53668 * q ) - 12211 * q ); 00038 if ( rnd_seed < 0 ) 00039 rnd_seed += 2147483563L; 00040 return rnd_seed; 00041 }
1.5.7.1