Skip to content

Commit

Permalink
added comments and examples for the new statistical tests functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MFormenti committed Feb 19, 2024
1 parent 798866f commit c75617f
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -40,6 +40,27 @@ def __init__(self, cipher):
@staticmethod
def dieharder_statistical_tests(input_file):

"""
Run the run_dieharder_statistical_tests_tool_interactively function and process its output with the parse_output function
to standardize it for the Report class
INPUT:
- ``input_file`` -- **str**; file containing the bit streams
OUTPUT:
a python dictionary representing the parsed output of the run_dieharder_statistical_tests_tool_interactively function
EXAMPLES:
from claasp.cipher_modules.statistical_tests.dieharder_statistical_tests import DieharderTests
result = StatisticalTests.dieharder_statistical_test(f'claasp/cipher_modules/statistical_tests/input_data_example')
"""


DieharderTests.run_dieharder_statistical_tests_tool_interactively(input_file)

report = DieharderTests.parse_report(f'dieharder_test_output.txt')
30 changes: 30 additions & 0 deletions claasp/cipher_modules/statistical_tests/nist_statistical_tests.py
Original file line number Diff line number Diff line change
@@ -44,10 +44,40 @@ def __init__(self, cipher):
def nist_statistical_tests(input_file, bit_stream_length=10000, number_of_bit_streams=10,
input_file_format=1,
statistical_test_option_list=15 * '1'):
"""
Run the run_nist_statistical_tests_tool_interactively function and process its output with the parse_output function
to standardize it for the Report class
INPUT:
- ``input_file`` -- **str**; file containing the bit streams
- ``bit_stream_length`` -- **integer**; bit stream length
- ``number_of_bit_streams`` -- **integer**; number of bit streams in `input_file`
- ``input_file_format`` -- **integer**; `input_file` format. Set to 0 to indicate a file containing a binary
string in ASCII, or 1 to indicate a binary file
- ``test_type`` -- **str**; the type of the test to run
- ``statistical_test_option_list`` -- **str** (default: `15 * '1'`); a binary string of size 15. This string is
used to specify a set of statistical tests we want to run
OUTPUT:
a python dictionary representing the parsed output of the run_nist_statistical_tests_tool_interactively function
EXAMPLES:
from claasp.cipher_modules.statistical_tests.nist_statistical_tests import StatisticalTests
result = StatisticalTests.nist_statistical_test(f'claasp/cipher_modules/statistical_tests/input_data_example')
"""


StatisticalTests.run_nist_statistical_tests_tool_interactively(input_file, bit_stream_length, number_of_bit_streams,
input_file_format,
statistical_test_option_list)



report = StatisticalTests.parse_report(f'claasp/cipher_modules/statistical_tests/finalAnalysisReportExample.txt')

return report

0 comments on commit c75617f

Please sign in to comment.