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

Testing random byte quality with swrandom

This section demonstrates how to test the quality of random bytes generated by the device on Ubuntu OS using swrandom kernel module. However, similar steps can be performed on CentOS or Red Hat systems as well. Read section Building and loading the swrandom kernel module with Linux that explains how to load the swrandom module.

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:

cat /dev/swrandom | 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: 9996
rngtest: FIPS 140-2 failures: 4
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: 1
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=423.855; avg=3891.754; max=9536.743)Mibits/s
rngtest: FIPS tests speed: (min=26.676; avg=39.110; max=42.386)Mibits/s
rngtest: Program run time: 4946762 microseconds

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

sudo dd if=/dev/swrandom bs=10 count=12000000 | ent

The output may look something like this:

12000000+0 records in
12000000+0 records out
120000000 bytes (120 MB) copied, 42.6431 s, 2.8 MB/s
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 245.22, and randomly
would exceed this value 50.00 percent of the times.

Arithmetic mean value of data bytes is 127.4974 (127.5 = random).
Monte Carlo value for Pi is 3.141486000 (error 0.00 percent).
Serial correlation coefficient is 0.000016 (totally uncorrelated = 0.0).

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

cat /dev/swrandom | 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.85e+06  |1581281168|
#=============================================================================#
        test_name   |ntup| tsamples |psamples|  p-value |Assessment
#=============================================================================#
   diehard_birthdays|   0|       100|     100|0.67854374|  PASSED
      diehard_operm5|   0|   1000000|     100|0.67569037|  PASSED
  diehard_rank_32x32|   0|     40000|     100|0.47867080|  PASSED
    diehard_rank_6x8|   0|    100000|     100|0.62835183|  PASSED
   diehard_bitstream|   0|   2097152|     100|0.11560427|  PASSED