Giter Site home page Giter Site logo

a-variant-of-nist-sp-800-22-test-suit's Introduction

Introduction

    A set of statistical tests for randomness is described in NIST SP 800-22 Revision 1a A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications. The NIST Statistical Test Suit is a software tool released by NIST. The document and the software can be found on the website: https://csrc.nist.gov/Projects/Random-Bit-Generation/Documentation-and-Software . A variant of NIST Statistical Test Suit is presented here. The differences are listed in the table below:

NIST Test Suit (version 2.1.2) The variant
suported OS Linux only Linux, Windows
funcitons generating random number, testing random number testing random number only
result display The results are not in the finalAnalysisReport.txt file. They are in the results.txt files in the individual test directories (when running the sample data files these test directories are in the directory experiments/AlgorithmTesting/) . The results are gathered up and displayed on the standard output device (stdout).
input data file format in ASCII format, in binary format in binary format only
the length in bits of a block in some tests fixed value, hard-coded in the source files can be set in config.json file
global variable A global variable epsilon is used. The global variable is not used. Using global variable should be avoided.
variable naming Names of some variables are hard to understand, such as n, M. Some variables are renamed. The new names are easy to understand, such as blockLen, blockCount.
function declaration Not all functions are declared in header files. Function declarations and relative header files have been added.
input length check absence Input length check has been added.

Set parameter values

    Some parameter values can be set in config.json file. They are listed in the table below:

Parameter values Test Range (count in bits)
the length of each block Frequency Test within a Block [2, n] (n is the length of the bit string.)
the length of each template Non-overlapping Template Matching Test [2, 21]
the length of the template Overlapping Template Matchings Test NIST recommends m = 9 or m = 10.
the length of each block Linear Complexity Test [500, 5000]
the length of each block Serial Test [3, floor(ln(n) / ln(2)) - 2)
the length of each block Approximate Entropy Test [2, floor(ln(n) / ln(2)) - 5)

Compile

  • with Visual Studio on Windows:
    nmake -f Makefile_for_VS.txt
  • with GCC on Linux:
    make -f Makefile_for_Linux.txt

Run

  • run the executable file rnd_test:
    rnd_test random_number_file
    e.g. rnd_test data.sha1 (on Windows) or ./rnd_test data.sha1 (on Linux)
  • Tip: the output can be re-directed to a file by using pipe command:
    e.g. rnd_test data.sha1 > log.txt (on Windows) or ./rnd_test data.sha1 > log.txt (on Linux)
  • Note:
    1. The executable file rnd_test and the folder templates must be put into the same directory.
    2. data.sha1 is a sample data file included in folder sts-2.1.2\data of NIST Statistical Test Suit. It is in binary format.
    3. The recommended length of the input data file in NIST SP 800-22 Revision 1a is 1,000,000 bits (i.e. about 122K Bytes). If the length is too small or to big, some tests cannot be performed. And even if the length is about 1,000,000 bits, some tests cannot be performed occasionally.

Screenshot

    Partial results:
ScreenShot01

ScreenShot02

License

    This work is a compound of revised NIST Statistical Test Suit (v2.1.2), cJSON (v1.7.12) and few files written by myself. It's hard to find a common license suitable for it. Maybe distinct licenses should be used for specific files.

File License
files copied or revised from NIST Statistical Test Suit software disclaimer on: https://csrc.nist.gov/Projects/Random-Bit-Generation/Documentation-and-Software
cJSON files MIT License, claimed on: https://github.com/DaveGamble/cJSON
few files written by myself MIT License (https://mit-license.org/), marked at the beginning of those files

a-variant-of-nist-sp-800-22-test-suit's People

Contributors

greendow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.