Index: base/rand_util_win.cc |
diff --git a/base/rand_util_win.cc b/base/rand_util_win.cc |
index 391fe5b9e61d6f48f413b97f3f3f536dd38d5da0..35f2d2e863ab83f84e0c00dffe19872f808fa43a 100644 |
--- a/base/rand_util_win.cc |
+++ b/base/rand_util_win.cc |
@@ -28,4 +28,14 @@ uint64 RandUint64() { |
return (static_cast<uint64>(first_half) << 32) + second_half; |
} |
+void RandBytes(void* output, size_t output_length) { |
+ uint64 random_int; |
bradn
2014/01/22 21:56:12
Any reason not to use:
CryptGenRandom ?
http://msd
wtc
2014/01/22 22:29:09
There is a better Windows function: RtlGenRandom.
|
+ const size_t random_int_size = sizeof(random_int); |
+ for (size_t i = 0; i < output_length; i += random_int_size) { |
+ random_int = base::RandUint64(); |
+ size_t copy_count = std::min(output_length - i, random_int_size); |
wtc
2014/01/22 22:29:09
|copy_count| can also be 'const'. (I don't do this
DaleCurtis
2014/01/22 22:54:14
Done.
|
+ memcpy(((uint8*)output) + i, &random_int, copy_count); |
+ } |
+} |
+ |
} // namespace base |