Testing random byte quality with ‘alrng’

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

Testing with ‘rngtest’

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

sudo alrng -e -o /dev/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: 9994
rngtest: FIPS 140-2 failures: 6
rngtest: FIPS 140-2(2001-10-10) Monobit: 1
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 3
rngtest: FIPS 140-2(2001-10-10) Long run: 2
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=131.426; avg=5479.122; max=19531250.000)Kibits/s
rngtest: FIPS tests speed: (min=2.282; avg=54.358; max=59.980)Mibits/s
rngtest: Program run time: 40174803 microseconds

Testing with ‘ent’

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

sudo alrng -e -o /dev/stdout -n 120000000 -c none -m none | ent

The output may look something like this:

dev/stdout -n 120000000 -c none -m none | ent
Entropy = 7.999998 bits per byte.

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

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

Arithmetic mean value of data bytes is 127.4932 (127.5 = random).
Monte Carlo value for Pi is 3.141537200 (error 0.00 percent).
Serial correlation coefficient is -0.000119 (totally uncorrelated = 0.0).

Testing with ‘dieharder’

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

sudo alrng -e -o /dev/stdout -c none -m none | 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.84e+06  |2432271805|
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
   diehard_birthdays|   0|       100|     100|0.60604035|  PASSED  
      diehard_operm5|   0|   1000000|     100|0.82802747|  PASSED  
  diehard_rank_32x32|   0|     40000|     100|0.42348084|  PASSED  
    diehard_rank_6x8|   0|    100000|     100|0.59847910|  PASSED  
   diehard_bitstream|   0|   2097152|     100|0.71632814|  PASSED