MCPcopy Create free account
hub / github.com/numpy/numpy / rk_devfill

Function rk_devfill

numpy/random/src/mt19937/randomkit.c:506–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504}
505
506rk_error rk_devfill(void *buffer, size_t size, int strong) {
507#ifndef _WIN32
508 FILE *rfile;
509 int done;
510
511 if (strong) {
512 rfile = fopen(RK_DEV_RANDOM, "rb");
513 } else {
514 rfile = fopen(RK_DEV_URANDOM, "rb");
515 }
516 if (rfile == NULL) {
517 return RK_ENODEV;
518 }
519 done = fread(buffer, size, 1, rfile);
520 fclose(rfile);
521 if (done) {
522 return RK_NOERR;
523 }
524#else
525
526#ifndef RK_NO_WINCRYPT
527 HCRYPTPROV hCryptProv;
528 BOOL done;
529
530 if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
531 CRYPT_VERIFYCONTEXT) ||
532 !hCryptProv) {
533 return RK_ENODEV;
534 }
535 done = CryptGenRandom(hCryptProv, size, (unsigned char *)buffer);
536 CryptReleaseContext(hCryptProv, 0);
537 if (done) {
538 return RK_NOERR;
539 }
540#endif
541
542#endif
543 return RK_ENODEV;
544}
545
546rk_error rk_altfill(void *buffer, size_t size, int strong, rk_state *state) {
547 rk_error err;

Callers 2

rk_randomseedFunction · 0.85
rk_altfillFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected