A Statistical Test Suite

for Pseudo-Random Number Generators

used in Cryptographic Applications

The Statistical Tests Suite was proposed by the National Institute of Standards and Technology (NIST) in 2001 and implemented in C. The Statistical_Tests class re-implements all tests in C++ using the code from NIST (v1.5) and GNU Scientific Library (GSL).

Each statistical test is implemented as a member function whose output is the vector of computed P-values. Computation details of each test can be written into an ASCII file.

A number of 16 statistical tests are implemented:
  1. Frequency (Monobit) Test (Statistical_Tests::Frequency)
  2. Frequency Test within a Block (Statistical_Tests::BlockFrequency)
  3. Cumulative Sums (Cusum) Test (Statistical_Tests::CumulativeSums)
  4. Runs Test (Statistical_Tests::Runs)
  5. Test for the Longest Run of Ones in a Block (Statistical_Tests::LongestRunOfOnes)
  6. Binary Matrix Rank Test (Statistical_Tests::Rank)
  7. Discrete Fourier Transform (Spectral) Test (Statistical_Tests::DiscreteFourierTransform)
  8. Non-overlapping Template Matching Test (Statistical_Tests::NonOverlappingTemplateMatchings)
  9. Overlapping Template Matching Test (Statistical_Tests::OverlappingTemplateMatchings)
  10. Maurer's ''Universal Statistical`` Test (Statistical_Tests::Universal)
  11. Approximate Entropy Test (Statistical_Tests::ApproximateEntropy)
  12. Random Excursions Test (Statistical_Tests::RandomExcursions)
  13. Random Excursions Variant Test (Statistical_Tests::RandomExcursionsVariant)
  14. Serial Test (Statistical_Tests::Serial)
  15. Lempel-Ziv Compression Test (Statistical_Tests::LempelZivCompression)
  16. Linear Complexity Test (Statistical_Tests::LinearComplexity)
For further details download the sources and generate with Doxygen the HTML help.

In order to use Statistical_Tests class, the GSL must be installed. For example, on a Linux platform, assuming that the GSL  and its headers are installed, the compilation commands are (see README.md for further details):
mkdir build
cd build
cmake ..
The compilation should work on Windows by using cmake for Windows, but it has not been tested yet.

Matlab Interface

It is possible to call Statistical_Tests class member functions from Matlab using an interface function between Matlab and C++ written in C++. The Matlab function must be called as follows:
[freq block_freq cum_sum runs longest_run rank dft non_overlap overlap univ app_en rand_ex rand_ex_v serial lz_compression complexity] = C_test(nb_bits, offset_bytes, input_file_name);
The compilation command for the interface function is:
mex -lgsl src/StatisticalTests.cpp src/c_statisticaltests.cpp   
Cristea Bogdan,
Jun 16, 2012, 11:44 AM