Ch12.5: Security Considerations

Why These Random Sources Are Secure

The ibuf_white_hole_engine and platform-specific random sources are suitable for cryptographic use because they:

When to Use

When Not to Use Directly

Common Mistake: Modulo Bias

Never use modulo (value % range) to generate random numbers in a range. This creates biased distributions due to the pigeonhole principle.

Always use ::std::uniform_int_distribution or other distributions from <random>. The distribution uses rejection sampling to ensure each value in the range has exactly the same probability.

See Ch12.2: The Pigeonhole Principle for details.

Key Takeaways