PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
Go to the source code of this file.
Functions | |
static void | swap_byte (uint8_t *a, uint8_t *b) |
Swaps the bytes pointed to by A and B. More... | |
void | random_init (unsigned seed) |
Initializes or reinitializes the PRNG with the given SEED. More... | |
void | random_bytes (void *buf_, size_t size) |
Writes SIZE random bytes into BUF. More... | |
unsigned long | random_ulong (void) |
Returns a pseudo-random unsigned long. More... | |
Variables | |
static uint8_t | s [256] |
RC4-based pseudo-random number generator (PRNG). More... | |
static uint8_t | s_i |
static uint8_t | s_j |
i, j. More... | |
static bool | inited |
Already initialized? More... | |
void random_bytes | ( | void * | buf_, |
size_t | size | ||
) |
Writes SIZE random bytes into BUF.
Definition at line 54 of file random.c.
References buf, inited, random_init(), s, s_i, s_j, and swap_byte().
Referenced by main(), random_ulong(), seq_test(), and test_main().
void random_init | ( | unsigned | seed | ) |
Initializes or reinitializes the PRNG with the given SEED.
Definition at line 34 of file random.c.
References inited, s, s_i, s_j, and swap_byte().
Referenced by consume_some_resources_and_die(), main(), parse_options(), random_bytes(), and test_main().
unsigned long random_ulong | ( | void | ) |
Returns a pseudo-random unsigned long.
Use random_ulong() % n to obtain a random number in the range 0...n (exclusive).
Definition at line 78 of file random.c.
References random_bytes().
Referenced by consume_some_resources_and_die(), expand(), pick_pivot(), shuffle(), test(), and write_some_bytes().
Swaps the bytes pointed to by A and B.
Definition at line 25 of file random.c.
Referenced by random_bytes(), and random_init().
|
static |
Already initialized?
Definition at line 21 of file random.c.
Referenced by init(), random_bytes(), and random_init().
|
static |
RC4-based pseudo-random number generator (PRNG).
RC4 is a stream cipher. We're not using it here for its cryptographic properties, but because it is easy to implement and its output is plenty random for non-cryptographic purposes.
See http://en.wikipedia.org/wiki/RC4_(cipher) for information on RC4. RC4 state. S[].
Definition at line 17 of file random.c.
Referenced by __vprintf(), arc4_crypt(), arc4_init(), atoi(), cksum(), hash_string(), parse_octal_field(), puts(), random_bytes(), random_init(), shutdown_power_off(), strtok_r(), and udiv64().
|
static |
Definition at line 18 of file random.c.
Referenced by random_bytes(), and random_init().
|
static |