MCPcopy Create free account
hub / github.com/ddnet/ddnet / secure_random_fill

Function secure_random_fill

src/base/secure.cpp:83–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void secure_random_fill(void *bytes, unsigned length)
84{
85 ensure_secure_random_init();
86#if defined(CONF_FAMILY_WINDOWS)
87 if(!CryptGenRandom(secure_random_data.provider, length, (unsigned char *)bytes))
88 {
89 const DWORD LastError = GetLastError();
90 dbg_assert_failed("CryptGenRandom failure (%ld '%s')", LastError, windows_format_system_message(LastError).c_str());
91 }
92#else
93 dbg_assert(length == io_read(secure_random_data.urandom, bytes, length), "io_read returned with a short read");
94#endif
95}
96
97// From https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2.
98static unsigned int find_next_power_of_two_minus_one(unsigned int n)

Callers 15

OnInitMethod · 0.85
CScoreMethod · 0.85
RunMethod · 0.85
InitChecksumMethod · 0.85
CServerBrowserMethod · 0.85
RefreshMethod · 0.85
RequestImplMethod · 0.85
StunMessagePrepareFunction · 0.85
GenerateToken7Method · 0.85
GenerateTokenMethod · 0.85
RandomUuidFunction · 0.85
OpenMethod · 0.85

Calls 3

io_readFunction · 0.85

Tested by 2

TESTFunction · 0.68
TESTFunction · 0.68