Pseudo-Random Number Generator validate testing suite
The NIST SP-800-22 test framework provides a standardized method for evaluating the randomness of random and pseudorandom number sequences. Developed by the National Institute of Standards and Technology (NIST), this suite is primarily used in cryptographic applications to assess the quality of random number generators.
These tests statistically assess whether a data sequence has been randomly generated, crucial for generating unpredictable cryptographic keys, initialization vectors, passwords, and other vital security elements.
example REPL command:
go run main.go -file rand_data/numbers.bin -all -template "0010111011" -block-size 100
To use this testing framework, prepare the sequence of data to be tested (The test file should contain at least 1000 data points.), perform each test, and interpret the results to evaluate the adequacy of the random number generator.
Typically, results are labeled PASS or FAIL based on their p-values
; a sequence passes a test if its p-value is greater than 0.01
, indicating decision rules in the document which is the pivot satisfactory randomness.
The suite includes various tests, each examining specific properties or patterns within the data. This includes frequency tests, block frequency tests, runs tests, matrix rank tests, and more, each designed to detect non-random occurrences and ensure the data does not follow predictable patterns.
The tests include all the tests specified in NIST SP-800-22 document. More detailed explanation of each tests please refer the NIST's document1. The sections and page numbers also refer to this document.
Section 2.1 p.24
This test checks the frequency of single bits to ensure that the occurrences of 0s and 1s are approximately the same within the sequence.
Section 2.2 p.26
It evaluates the frequency of bits within a block of data to check for balance, ensuring no uneven distribution of 0s and 1s.
Section 2.3 p.27
This test measures how frequently runs of consecutive identical bits occur, examining the sequence for high uniformity that might indicate non-randomness.
Section 2.4 p.29
Determines the length of the longest run of '1's in a specified block, assessing the sequence for unusual patterns.
Section 2.5 p.32
Uses the rank of matrices to evaluate the dimensional structure of the data, checking for linear dependencies.
Section 2.6 p.34
Analyzes the sequence in the frequency domain to detect periodic features, which could indicate predictability.
Section 2.7 p.36
Assesses how frequently certain predefined bit patterns appear within the sequence, checking for their unexpected repetition or rarity.
Section 2.8 p.39
Evaluates the frequency of overlapping patterns, looking for deviations from expected randomness.
Section 2.9 p.42
Minimum length of test case: 387,840
Measures the complexity of data sequences to evaluate their randomness, assessing the sequence’s entropy and compression potential.
Section 2.10 p.46
Evaluates how complex or simple a sequence can be described, providing insight into the sequence's algorithmic complexity.
Section 2.11, p.48
Checks for the frequency of repeating patterns within the sequence to detect structured deviations from randomness.
Section 2.12 p.51
Measures the entropy of the sequence, quantifying the degree of randomness or unpredictability.
Section 2.13 p.53
Analyzes whether the cumulative sum of the sequence deviates from expected behavior, indicating potential biases.
Section 2.14 p.55
Analyzes random deviations from the mean to assess patterns that could suggest non-randomness.
Section 2.15 p.60
Further examines random excursions using various states, providing additional analysis on deviations from randomness.