MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_secure_random

Function cbm_secure_random

src/foundation/secure_random.c:20–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include <bcrypt.h>
19
20bool cbm_secure_random(void *buffer, size_t length) {
21 if (!buffer && length != 0) {
22 return false;
23 }
24 uint8_t *cursor = buffer;
25 while (length > 0) {
26 ULONG chunk = length > UINT32_MAX ? UINT32_MAX : (ULONG)length;
27 if (BCryptGenRandom(NULL, cursor, chunk, BCRYPT_USE_SYSTEM_PREFERRED_RNG) < 0) {
28 return false;
29 }
30 cursor += chunk;
31 length -= chunk;
32 }
33 return true;
34}
35
36#else
37

Callers 4

cbm_mkdtempFunction · 0.85
win_generation_nonceFunction · 0.85
host_state_prepareFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected