6 /* RC4-based pseudo-random state. */
8 static uint8_t s_i, s_j;
12 swap_byte (uint8_t *a, uint8_t *b)
20 random_init (unsigned seed)
22 uint8_t *seedp = (uint8_t *) &seed;
29 for (i = 0; i < 256; i++)
31 for (i = j = 0; i < 256; i++)
33 j += s[i] + seedp[i % sizeof seed];
34 swap_byte (s + i, s + j);
42 random_bytes (void *buf_, size_t size)
47 for (buf = buf_; size-- > 0; buf++)
53 swap_byte (s + s_i, s + s_j);
55 s_k = s[s_i] + s[s_j];
60 /* Returns a pseudo-random unsigned long. */
65 random_bytes (&ul, sizeof ul);