MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / get_sys_random_bytes

Function get_sys_random_bytes

libcppcryptfs/util/util.cpp:419–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418
419bool
420get_sys_random_bytes(unsigned char *buf, DWORD len)
421{
422
423 HCRYPTPROV hProvider = NULL;
424
425 if (!CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
426 return false;
427 }
428
429 if (!CryptGenRandom(hProvider, len, buf)) {
430 CryptReleaseContext(hProvider, 0);
431 return false;
432 }
433
434 CryptReleaseContext(hProvider, 0);
435
436 return true;
437
438}
439
440
441

Callers 7

GetRandomBytesMethod · 0.85
encrypt_string_gcmFunction · 0.85
FinalizeMethod · 0.85
get_random_bytesFunction · 0.85
encrypt_keyMethod · 0.85
createMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected