-1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ I'm voting to close this question as off-topic because code requests are off topic, we require concise questions, not requests for help. $\endgroup$ – Maarten Bodewes May 6 '19 at 21:09
2
$\begingroup$

A few points:-

  1. The FIPS 140-2 tests are wrapped up within the rngtest program, 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).

  1. 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.

  2. rngtest is 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.

  3. I assume that there is some form of cryptographic primitive within your PRBG as this test cannot prove security.

$\endgroup$
4
  • $\begingroup$ thank you. I will try this out! $\endgroup$ – Taku Angwa Otto CHE May 9 '19 at 23:09
  • $\begingroup$ hi. please I need help tweaking the code to produce bytes. It produces characters at the moment and the rngtest fails woefully. I am programming on matlab. $\endgroup$ – Taku Angwa Otto CHE May 16 '19 at 3:23
  • $\begingroup$ @TakuAngwaOttoCHE Sorry Taku, I don't use matlab, but does anything like this help? Remember that a binary version of equivalent text will be smaller as an ASCII file doesn't fill up all of the available bits in the bytes (depending on the locale). So you 'll need to make a lot more than 20,000 characters. Maybe 8 times as much. And don't forget any carriage returns etc... $\endgroup$ – Paul Uszak May 16 '19 at 10:37
  • $\begingroup$ Thank you so much $\endgroup$ – Taku Angwa Otto CHE May 16 '19 at 22:38
0
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ thanks. I will check it out too $\endgroup$ – Taku Angwa Otto CHE May 16 '19 at 3:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.