Function RtlGenRandom [src]
Call RtlGenRandom() instead of CryptGetRandom() on Windows
https://github.com/rust-lang-nursery/rand/issues/111
https://bugzilla.mozilla.org/show_bug.cgi?id=504270
Prototype
pub fn RtlGenRandom(output: []u8) RtlGenRandomError!void
Parameters
output: []u8
Possible Errors
Source
pub fn RtlGenRandom(output: []u8) RtlGenRandomError!void {
var total_read: usize = 0;
var buff: []u8 = output[0..];
const max_read_size: ULONG = maxInt(ULONG);
while (total_read < output.len) {
const to_read: ULONG = @min(buff.len, max_read_size);
if (advapi32.RtlGenRandom(buff.ptr, to_read) == 0) {
return unexpectedError(GetLastError());
}
total_read += to_read;
buff = buff[to_read..];
}
}