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

Function ensure_secure_random_init

src/base/secure.cpp:33–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31static struct SECURE_RANDOM_DATA secure_random_data = {};
32
33static void ensure_secure_random_init()
34{
35 std::call_once(secure_random_data.initialized_once_flag, []() {
36#if defined(CONF_FAMILY_WINDOWS)
37 if(!CryptAcquireContext(&secure_random_data.provider, nullptr, nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
38 {
39 const DWORD LastError = GetLastError();
40 dbg_assert_failed("Failed to initialize secure random: CryptAcquireContext failure (%ld '%s')", LastError, windows_format_system_message(LastError).c_str());
41 }
42#else
43 secure_random_data.urandom = io_open("/dev/urandom", IOFLAG_READ);
44 dbg_assert(secure_random_data.urandom != nullptr, "Failed to initialize secure random: failed to open /dev/urandom");
45#endif
46 });
47}
48
49void generate_password(char *buffer, unsigned length, const unsigned short *random, unsigned random_length)
50{

Callers 1

secure_random_fillFunction · 0.85

Calls 2

io_openFunction · 0.85

Tested by

no test coverage detected