Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

...

Noncompliant Code Example

In this This noncompliant code example improves over the previous noncompliant code example , by seeding the random number generation engine is seeded with the current time. This code is an improvement over the previous noncompliant code example, but However, this approach is still unsuitable when an attacker can control the time at which the seeding is executed. Predictable seed values can result in exploits when the subverted PRNG is used.

...

This compliant solution uses std::random_device to generate a random seed value to seed for seeding the Mersenne Twister engine object. The values generated by std::random_device are nondeterministic random numbers when possible, relying on random number generation devices, such as /dev/random. When such a device is not available, std::random_device may employ a random number engine; however, the initial value generated should have sufficient randomness to serve as a seed value.

...