#include <gpxe/crypto.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | get_random_bytes (void *buf, size_t len) |
| Get cryptographically strong random bytes. | |
Currently the cryptographic part is not implemented, and this just uses random().
Definition in file crandom.c.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void get_random_bytes | ( | void * | buf, | |
| size_t | len | |||
| ) |
Get cryptographically strong random bytes.
| buf | Buffer in which to store random bytes | |
| len | Number of random bytes to generate |
Definition at line 41 of file crandom.c.
Referenced by forcedeth_probe(), and wpa_handle_1_of_4().
00042 { 00043 u8 *bufp = buf; 00044 00045 /* 00046 * Somewhat arbitrarily, choose the 0x00FF0000-masked byte 00047 * returned by random() as having good entropy. PRNGs often 00048 * don't provide good entropy in lower bits, and the top byte 00049 * might show a pattern because of sign issues. 00050 */ 00051 00052 while ( len-- ) { 00053 *bufp++ = ( random() >> 16 ) & 0xFF; 00054 } 00055 }
1.5.7.1