# Random number generator testing

Random number generation is typically a two-step process. First you create a source of uniformly distributed random numbers, then you transform these numbers into the form you need.

Testing random number generators is very different depending on whether you’re testing the original source of bits or testing the transformation of those bits.

Testing random number generators for use in cryptographic applications is different still. Statistical quality is necessary, but it’s not enough.

This page discusses each of these testing scenarios below: uniform, non-uniform, and cryptographic. We offer testing services for each case.

## Testing uniform RNGs

One of the earliest and still most widely known test suites for random number generators was George Marsaglia’s DIEHARD suite. This suite evolved into the DIEHARDER test suite now maintained by Robert G. Brown and colleagues. More recent test suites include Practically Random (PractRand) and TestU01 (BigCrush).

These tests, while statistically rigorous, are not easy to use and the results can be hard to interpret. We will run the tests for you and help you interpret the results.

## Testing nonuniform RNGs

Not many people develop their own uniform random number generator. Far more people trust a third party RNG as a source of uniform random values then transform the values to meet their needs: randomly permuting lists, generating random points on a sphere, sampling from a gamma distribution, etc.

Starting with a high quality uniform random number generator does little good if the output is not transformed appropriately for the task at hand. We provide validation for not just a random number generator but also the statistical application of that generator.

## Random bit generation (RBG)

The necessary quality of a source of randomness depends on how that randomness is to be used. If you’re generating random bits to turn them into floating point numbers, say to use in Monte Carlo integration, then the least significant bits are literally not that significant. A lack of randomness in the least significant bits may not be a concern. But in other applications, such as random key generation, all bits are equally significant, and the quality demands on the RBG are much higher.

## Cryptographic random number generation

For cryptographic applications, statistical quality is necessary but not sufficient. A random number generator can have excellent statistical properties and yet be cryptographically weak.

For example, while the popular Mersenne Twister is suitable for most statistical applications, it is not appropriate for use in cryptography because its future output can be predicted from past output by solving a system of linear recurrence equations.

The NIST Statistical Test Suite (STS) is recommended for testing CSPRNGs (cryptographically secure pseudorandom number generators) though it in no way guarantees an RNG is secure. The Mersenne Twister, for example, passes STS without any issues. STS is not a very demanding test for statistical quality, much less cryptographic quality, but it is a test any CSPRNG should pass. Government agencies, for example, want to see that a generator passes the STS tests.

## NIST and ANSI Standards compliance

Because random bit generation is subtle, and security depends on doing it well, NIST and ANSI developed standards to guide its implementation. We can help you comply with the recommendations in the following publications.

• NIST SP 800-90A: Recommendation for Random Number Generation Using Deterministic Random Bit Generators
• NIST SP 800-90B: Recommendation for the Entropy Sources Used for Random Bit Generation
• American National Standard for Financial Services ANSI X9.82, parts 1–4

In particular, we can assist with the following requirement from NIST SP 800-90B:

The submitter shall provide mathematical evidence that the component is suitable to be used to condition the noise source output, and does not significantly reduce the entropy rate of the entropy source output.

## Free consultation

Get started with a free consultation to discuss your testing project.

Trusted consultants to some of the world’s leading companies