TestU01¶
Module for interacting with TestU01.
This module provides the test_file() function to test a file of random data using
the NIST battery of tests implemented by TestU01.
A modified version of TestU01 is bundled with crypto-condor, which adds the NIST battery from the
existing tests. This version has to compiled and installed locally: it requires make and
gcc to compile. Installation is done with install_testu01(), which should be
called by any function in this module that uses TestU01.
Installation¶
- crypto_condor.primitives.TestU01.get_testu01_dir()¶
- Returns the installation path of TestU01. 
- crypto_condor.primitives.TestU01.install_testu01(*, debug=False)¶
- Installs TestU01. - Checks if the path returned by - get_testu01_dir()exists. If not, copies the necessary files to that path. It then checks whether TestU01 is compiled, and compiles it if not.- Keyword Arguments:
- debug – If True, the compilation output is not captured by subprocess, displaying the full output on stdout. 
 
Testing a file¶
- crypto_condor.primitives.TestU01.test_file(filename, *, bit_count=0)¶
- Tests the output of a PRNG using TestU01. - Our NIST battery requires at least 500 bits. - Parameters:
- filename (str) – The name of the file to test. 
- Keyword Arguments:
- bit_count – The number of bits to read. Must be less or equal to the size of the file, and at least 500. 
- Returns:
- A dictionary of results, containing a single - Results.
- Raises:
- ValueError – If the bit count is strictly positive and less than 500, or the actual file size if less than 500 bits. 
- Return type:
 - Changed in version 2025.03.12: - test_filenow returns ResultsDict containing a single Results for a TestU01 run.