MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetDevURandom

Function GetDevURandom

src/random.cpp:183–199  ·  view source on GitHub ↗

Fallback: get 32 bytes of system entropy from /dev/urandom. The most * compatible way to get cryptographic randomness on UNIX-ish platforms. */

Source from the content-addressed store, hash-verified

181 * compatible way to get cryptographic randomness on UNIX-ish platforms.
182 */
183static void GetDevURandom(unsigned char *ent32)
184{
185 int f = open("/dev/urandom", O_RDONLY);
186 if (f == -1) {
187 RandFailure();
188 }
189 int have = 0;
190 do {
191 ssize_t n = read(f, ent32 + have, NUM_OS_RANDOM_BYTES - have);
192 if (n <= 0 || n + have > NUM_OS_RANDOM_BYTES) {
193 close(f);
194 RandFailure();
195 }
196 have += n;
197 } while (have < NUM_OS_RANDOM_BYTES);
198 close(f);
199}
200#endif
201
202/** Get 32 bytes of system entropy. */

Callers 1

GetOSRandFunction · 0.85

Calls 1

RandFailureFunction · 0.85

Tested by

no test coverage detected