Testing random byte quality with swrng

This section demonstrates how to test the quality of random bytes generated by the device on Ubuntu OS. However, similar steps can be performed on CentOS or Red Hat systems as well.

Make sure the rngtest, ent and dieharder utilities are installed using the following commands:

sudo apt-get install rng-tools
sudo apt-get install ent
sudo apt-get install dieharder

For using rngtest utility, run the following command for downloading and testing 200000032 of random bits:

sudo swrng -dd -fn STDOUT | rngtest -c 10000

The output may look something like this (the number of failures must be very low compared with the number of successes):

rngtest: starting FIPS tests...
rngtest: bits received from input: 200000032
rngtest: FIPS 140-2 successes: 9993
rngtest: FIPS 140-2 failures: 7
rngtest: FIPS 140-2(2001-10-10) Monobit: 1
rngtest: FIPS 140-2(2001-10-10) Poker: 1
rngtest: FIPS 140-2(2001-10-10) Runs: 2
rngtest: FIPS 140-2(2001-10-10) Long run: 3
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=268.641; avg=4061.732; max=19073.486)Mibits/s
rngtest: FIPS tests speed: (min=28.596; avg=39.242; max=41.285)Mibits/s
rngtest: Program run time: 5045884 microseconds

For using ent utility, run the following command for downloading and testing 120,000,000 of random bytes:

sudo swrng -dd -fn STDOUT -nb 120000000 | ent

The output may look something like this:

Entropy = 7.999999 bits per byte.

Optimum compression would reduce the size
of this 120000000 byte file by 0 percent.

Chi square distribution for 120000000 samples is 239.23, and randomly
would exceed this value 75.29 percent of the times.

Arithmetic mean value of data bytes is 127.4971 (127.5 = random).
Monte Carlo value for Pi is 3.141073400 (error 0.02 percent).
Serial correlation coefficient is -0.000140 (totally uncorrelated = 0.0).

For using dieharder utility, run the following command (it may take up to 16 hours to complete the test):

sudo swrng -dd -fn STDOUT | dieharder -a -g 200

The output may look something like this (to keep this page short we only included the first 13 lines of the output):

#=============================================================================#
##            dieharder version 3.31.1 Copyright 2003 Robert G. Brown          #
#=============================================================================#
   rng_name    |rands/second|   Seed   |
stdin_input_raw|  2.67e+06  |1292664540|
#=============================================================================#
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
#=============================================================================#
   diehard_birthdays|   0|       100|     100|0.71477273|  PASSED
      diehard_operm5|   0|   1000000|     100|0.86030318|  PASSED
  diehard_rank_32x32|   0|     40000|     100|0.84744819|  PASSED
    diehard_rank_6x8|   0|    100000|     100|0.28786307|  PASSED
   diehard_bitstream|   0|   2097152|     100|0.79008830|  PASSED