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

Function secure_rand_below

src/base/secure.cpp:109–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109int secure_rand_below(int below)
110{
111 unsigned int mask = find_next_power_of_two_minus_one(below);
112 dbg_assert(below > 0, "below must be positive");
113 while(true)
114 {
115 unsigned int n;
116 secure_random_fill(&n, sizeof(n));
117 n &= mask;
118 if((int)n < below)
119 {
120 return n;
121 }
122 }
123}

Callers 5

Con_LeakIpAddressMethod · 0.85
RunMethod · 0.85
UpdateDebugDummiesMethod · 0.85
TESTFunction · 0.85
TESTFunction · 0.85

Calls 2

secure_random_fillFunction · 0.85

Tested by 2

TESTFunction · 0.68
TESTFunction · 0.68