I designed a PRBG which produced 20000 bits. Please help me here. How do I test for randomness using FIPS 140-2 suit. I know what each test entails. Question is, can I get like a program/software/code that implements these test on a .txt file of the 20000 bits. Thanks in advance.
A few points:-
- The FIPS 140-2 tests are wrapped up within the
rngtestprogram, available in Linux as package
rng-tools5. I'll produce something like:-
rngtest: starting FIPS tests... rngtest: entropy source drained rngtest: bits received from input: 8388608 rngtest: FIPS 140-2 successes: 419 rngtest: FIPS 140-2 failures: 0 rngtest: FIPS 140-2(2001-10-10) Monobit: 0 rngtest: FIPS 140-2(2001-10-10) Poker: 0 rngtest: FIPS 140-2(2001-10-10) Runs: 0 rngtest: FIPS 140-2(2001-10-10) Long run: 0 rngtest: FIPS 140-2(2001-10-10) Continuous run: 0 rngtest: input channel speed: (min=340.598; avg=2424.694; max=6357.829)Mibits/s rngtest: FIPS tests speed: (min=35.585; avg=73.032; max=84.396)Mibits/s rngtest: Program run time: 115567 microseconds
If you appreciate the nature of those tests, you'll know that a small number of failures are to be expected (even though I didn't get any above).
20,000 bits isn't a lot of bits, RNG wise. Randomness needs to be appreciated within the context of the sample size. One block will be insufficient for anything other than checking for catastrophic failure. The tests are very slack, and a strongly compressed file will pass it. There are stronger tests that require many more bits.
rngtestis predicated on binary data, not ASCII which will cause the test to fail badly. You simply need to tweak your PRBG to produce bytes and not characters.
I assume that there is some form of cryptographic primitive within your PRBG as this test cannot prove security.
The trivial selftests for the (deterministic) RNG are listed in the standard, don’t think there is a external testsuite for those.
However the approved algorithms from SP 800-90A also have Test excessive testing and documentation requirements, but mostly for the deterministic part. NIST offers in 800-22 statistic Test Suite documentation for their tooling.
And you find the validation program here: https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators