diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 22 | ||||
| -rwxr-xr-x | test/cavp.py | 33 | ||||
| -rwxr-xr-x | test/nist.py | 25 | ||||
| -rw-r--r-- | test/toolkit.py | 19 |
4 files changed, 24 insertions, 75 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9a38d0a..2ee5728 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,17 +10,6 @@ add_test(NAME nist COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/nist.py" --path "$<TARGET_FILE_DIR:util_encrypt_block>" ) -add_test(NAME nist_boxes COMMAND Python3::Interpreter - "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/tools/ctest-driver.py" - run - --pass-regex [=[Succeeded: *30$]=] - --fail-regex [=[Failed: *[1-9]]=] - -- - "$<TARGET_FILE:Python3::Interpreter>" - "${CMAKE_CURRENT_SOURCE_DIR}/nist.py" - --path "$<TARGET_FILE_DIR:util_encrypt_block>" - --boxes -) add_test(NAME cavp COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/tools/ctest-driver.py" run @@ -31,17 +20,6 @@ add_test(NAME cavp COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/cavp.py" --path "$<TARGET_FILE_DIR:util_encrypt_block>" ) -add_test(NAME cavp_boxes COMMAND Python3::Interpreter - "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/tools/ctest-driver.py" - run - --pass-regex [=[Succeeded: *96$]=] - --fail-regex [=[Failed: *[1-9]]=] - -- - "$<TARGET_FILE:Python3::Interpreter>" - "${CMAKE_CURRENT_SOURCE_DIR}/cavp.py" - --path "$<TARGET_FILE_DIR:util_encrypt_block>" - --boxes -) add_test(NAME file COMMAND Python3::Interpreter "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/tools/ctest-driver.py" run diff --git a/test/cavp.py b/test/cavp.py index 047f254..928f6c9 100755 --- a/test/cavp.py +++ b/test/cavp.py @@ -101,42 +101,36 @@ class TestFile: for i in range(0, len(inputs), max_len): yield expected_output[i : i + max_len], inputs[i : i + max_len] - def _run_tests(self, tool, inputs, expected_output, use_boxes=False): + def _run_tests(self, tool, inputs, expected_output): for expected_output_chunk, input_chunk in self._split_into_chunks( expected_output, list(inputs) ): - actual_output = tool( - self.algorithm(), self.mode(), input_chunk, use_boxes=use_boxes - ) + actual_output = tool(self.algorithm(), self.mode(), input_chunk) if not verify_test_output(actual_output, expected_output_chunk): return TestExitCode.FAILURE return TestExitCode.SUCCESS - def run_encryption_tests(self, tools, use_boxes=False): + def run_encryption_tests(self, tools): logging.debug("Running encryption tests...") if not self.recognized(): return TestExitCode.SKIPPED try: keys, plaintexts, ciphertexts, init_vectors = self._encryption_data inputs = self._gen_inputs(keys, plaintexts, init_vectors) - return self._run_tests( - tools.run_encrypt_block, inputs, ciphertexts, use_boxes - ) + return self._run_tests(tools.run_encrypt_block, inputs, ciphertexts) except CalledProcessError as e: logging.error("Encountered an exception!") logging.exception(e) return TestExitCode.ERROR - def run_decryption_tests(self, tools, use_boxes=False): + def run_decryption_tests(self, tools): logging.debug("Running decryption tests...") if not self.recognized(): return TestExitCode.SKIPPED try: keys, plaintexts, ciphertexts, init_vectors = self._decryption_data inputs = self._gen_inputs(keys, ciphertexts, init_vectors) - return self._run_tests( - tools.run_decrypt_block, inputs, plaintexts, use_boxes - ) + return self._run_tests(tools.run_decrypt_block, inputs, plaintexts) except CalledProcessError as e: logging.error("Encountered an exception!") logging.exception(e) @@ -209,16 +203,14 @@ class TestArchive(zipfile.ZipFile): _script_dir = os.path.dirname(__file__) -def run_tests( - archive_path, tools_path=(), use_sde=False, use_boxes=False, verbose=False -): +def run_tests(archive_path, tools_path=(), use_sde=False, verbose=False): tools = Tools(tools_path, use_sde=use_sde) archive = TestArchive(archive_path) exit_codes = [] for test_file in archive.enum_test_files(): - exit_codes.append(test_file.run_encryption_tests(tools, use_boxes)) - exit_codes.append(test_file.run_decryption_tests(tools, use_boxes)) + exit_codes.append(test_file.run_encryption_tests(tools)) + exit_codes.append(test_file.run_decryption_tests(tools)) logging.info("Test exit codes:") logging.info("\tSkipped: %d", exit_codes.count(TestExitCode.SKIPPED)) @@ -255,13 +247,6 @@ def _parse_args(args=None): help="use Intel SDE to run the utilities", ) parser.add_argument( - "--boxes", - "-b", - action="store_true", - dest="use_boxes", - help='use the "boxes" interface', - ) - parser.add_argument( "--archive", "-a", dest="archive_path", diff --git a/test/nist.py b/test/nist.py index 447d34d..c51329c 100755 --- a/test/nist.py +++ b/test/nist.py @@ -184,7 +184,7 @@ class TestExitCode(Enum): SUCCESS, FAILURE, ERROR, SKIPPED = range(1, 5) -def run_encryption_test(tools, algorithm, mode, use_boxes=False): +def run_encryption_test(tools, algorithm, mode): logging.debug("Running encryption test...") logging.debug("Algorithm: %s", algorithm) logging.debug("Mode: %s", mode) @@ -195,7 +195,7 @@ def run_encryption_test(tools, algorithm, mode, use_boxes=False): iv = get_test_iv(algorithm, mode) expected_ciphertexts = get_test_ciphertexts(algorithm, mode) input_ = BlockInput(key, plaintexts, iv=iv) - actual_ciphertexts = tools.run_encrypt_block(algorithm, mode, input_, use_boxes) + actual_ciphertexts = tools.run_encrypt_block(algorithm, mode, input_) if verify_test_output(actual_ciphertexts, expected_ciphertexts): return TestExitCode.SUCCESS return TestExitCode.FAILURE @@ -205,7 +205,7 @@ def run_encryption_test(tools, algorithm, mode, use_boxes=False): return TestExitCode.ERROR -def run_decryption_test(tools, algorithm, mode, use_boxes=False): +def run_decryption_test(tools, algorithm, mode): logging.debug("Running decryption test...") logging.debug("Algorithm: %s", algorithm) logging.debug("Mode: %s", mode) @@ -216,7 +216,7 @@ def run_decryption_test(tools, algorithm, mode, use_boxes=False): iv = get_test_iv(algorithm, mode) expected_plaintexts = get_test_plaintexts(algorithm, mode) input_ = BlockInput(key, ciphertexts, iv=iv) - actual_plaintexts = tools.run_decrypt_block(algorithm, mode, input_, use_boxes) + actual_plaintexts = tools.run_decrypt_block(algorithm, mode, input_) if verify_test_output(actual_plaintexts, expected_plaintexts): return TestExitCode.SUCCESS return TestExitCode.FAILURE @@ -226,17 +226,13 @@ def run_decryption_test(tools, algorithm, mode, use_boxes=False): return TestExitCode.ERROR -def run_tests(tools_path=(), use_sde=False, use_boxes=False, verbose=False): +def run_tests(tools_path=(), use_sde=False, verbose=False): tools = Tools(tools_path, use_sde=use_sde) exit_codes = [] for algorithm, mode in get_tested_algorithms_and_modes(): - exit_codes.append( - run_encryption_test(tools, algorithm, mode, use_boxes=use_boxes) - ) - exit_codes.append( - run_decryption_test(tools, algorithm, mode, use_boxes=use_boxes) - ) + exit_codes.append(run_encryption_test(tools, algorithm, mode)) + exit_codes.append(run_decryption_test(tools, algorithm, mode)) logging.info("Test exit codes:") logging.info("\tSkipped: %d", exit_codes.count(TestExitCode.SKIPPED)) @@ -273,13 +269,6 @@ def _parse_args(args=None): help="use Intel SDE to run the utilities", ) parser.add_argument( - "--boxes", - "-b", - action="store_true", - dest="use_boxes", - help='use the "boxes" interface', - ) - parser.add_argument( "--verbose", "-v", action="store_true", help="verbose log output" ) return parser.parse_args(args) diff --git a/test/toolkit.py b/test/toolkit.py index b6c3cd3..d14ce23 100644 --- a/test/toolkit.py +++ b/test/toolkit.py @@ -135,32 +135,29 @@ class Tools: return args @staticmethod - def _block_settings_to_args(algorithm, mode, use_boxes=False): - args = [ + def _block_settings_to_args(algorithm, mode): + return [ "--algorithm", str(algorithm), "--mode", str(mode), ] - if use_boxes: - args.append("--use-boxes") - return args @staticmethod - def _build_block_args(algorithm, mode, inputs, use_boxes=False): - args = Tools._block_settings_to_args(algorithm, mode, use_boxes) + def _build_block_args(algorithm, mode, inputs): + args = Tools._block_settings_to_args(algorithm, mode) if isinstance(inputs, Iterable): args.extend(Tools._block_inputs_to_args(iter(inputs))) else: args.extend(inputs.to_args()) return args - def run_encrypt_block(self, algorithm, mode, inputs, use_boxes=False): - args = self._build_block_args(algorithm, mode, inputs, use_boxes) + def run_encrypt_block(self, algorithm, mode, inputs): + args = self._build_block_args(algorithm, mode, inputs) return self.run(self._ENCRYPT_BLOCK, args) - def run_decrypt_block(self, algorithm, mode, inputs, use_boxes=False): - args = self._build_block_args(algorithm, mode, inputs, use_boxes) + def run_decrypt_block(self, algorithm, mode, inputs): + args = self._build_block_args(algorithm, mode, inputs) return self.run(self._DECRYPT_BLOCK, args) @staticmethod |
