Commit 4af9fa96 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Document that its the job of the embedder to provide strong entropy for seeding the PRNG.

BUG=v8:2905
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/23965009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16888 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 94dd9ba0
......@@ -82,6 +82,11 @@ RandomNumberGenerator::RandomNumberGenerator() {
// We cannot assume that random() or rand() were seeded
// properly, so instead of relying on random() or rand(),
// we just seed our PRNG using timing data as fallback.
// This is weak entropy, but it's sufficient, because
// it is the responsibility of the embedder to install
// an entropy source using v8::V8::SetEntropySource(),
// which provides reasonable entropy, see:
// https://code.google.com/p/v8/issues/detail?id=2905
int64_t seed = Time::NowFromSystemTime().ToInternalValue() << 24;
seed ^= TimeTicks::HighResNow().ToInternalValue() << 16;
seed ^= TimeTicks::Now().ToInternalValue() << 8;
......
......@@ -42,6 +42,10 @@ namespace internal {
// If two instances of RandomNumberGenerator are created with the same seed, and
// the same sequence of method calls is made for each, they will generate and
// return identical sequences of numbers.
// This class uses (probably) weak entropy by default, but it's sufficient,
// because it is the responsibility of the embedder to install an entropy source
// using v8::V8::SetEntropySource(), which provides reasonable entropy, see:
// https://code.google.com/p/v8/issues/detail?id=2905
// This class is neither reentrant nor threadsafe.
class RandomNumberGenerator V8_FINAL {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment