| 1249 | |
| 1250 | #if USE_DEV_URANDOM |
| 1251 | static bool randomize_by_device(const char* device_name, int8* destbuf, int len) |
| 1252 | { |
| 1253 | static int rng_device = -1; |
| 1254 | |
| 1255 | if (-1 == rng_device) |
| 1256 | rng_device = open(device_name, O_RDONLY | O_NONBLOCK); |
| 1257 | |
| 1258 | if (rng_device >= 0) |
| 1259 | { |
| 1260 | int bytes_read = read(rng_device, destbuf, len); |
| 1261 | if (bytes_read == len) |
| 1262 | return true; |
| 1263 | } |
| 1264 | |
| 1265 | return false; |
| 1266 | } |
| 1267 | #else |
| 1268 | static bool gRandomizeBytesSeeded = false; |
| 1269 | #endif |