aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/nist-sp-800-38a.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-12-27 12:56:13 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-12-27 12:56:13 +0300
commit1db94ae5d2201edb5f9421c2c30be049efc678f6 (patch)
treecb67b8f1e8a04dda4de297cc011dc9de57d1e824 /test/nist-sp-800-38a.py
parentREADME update (diff)
downloadaes-tools-1db94ae5d2201edb5f9421c2c30be049efc678f6.tar.gz
aes-tools-1db94ae5d2201edb5f9421c2c30be049efc678f6.zip
utils: refactor command line parsing
Diffstat (limited to 'test/nist-sp-800-38a.py')
-rw-r--r--test/nist-sp-800-38a.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/nist-sp-800-38a.py b/test/nist-sp-800-38a.py
index 7189dde..05f0a39 100644
--- a/test/nist-sp-800-38a.py
+++ b/test/nist-sp-800-38a.py
@@ -146,7 +146,7 @@ def _assert_output(actual, expected):
class _TestExitCode:
SUCCESS, FAILURE, ERROR, SKIPPED = range(4)
-def _run_encryption_tests(tools, algo, mode):
+def _run_encryption_tests(tools, algo, mode, use_boxes=False):
logging.info('Running encryption tests...')
key = _keys[algo]
iv = None
@@ -154,13 +154,13 @@ def _run_encryption_tests(tools, algo, mode):
iv = _init_vectors[algo][mode]
ciphertexts = _ciphertexts[algo][mode]
_input = toolkit.EncryptionInput(key, _plaintexts, iv=iv)
- actual_output = tools.run_encrypt_block(algo, mode, _input)
+ actual_output = tools.run_encrypt_block(algo, mode, _input, use_boxes)
if _assert_output(actual_output, ciphertexts):
return _TestExitCode.SUCCESS
else:
return _TestExitCode.FAILURE
-def _run_decryption_tests(tools, algo, mode):
+def _run_decryption_tests(tools, algo, mode, use_boxes=False):
logging.info('Running decryption tests...')
key = _keys[algo]
iv = None
@@ -168,7 +168,7 @@ def _run_decryption_tests(tools, algo, mode):
iv = _init_vectors[algo][mode]
ciphertexts = _ciphertexts[algo][mode]
_input = toolkit.DecryptionInput(key, ciphertexts, iv=iv)
- actual_output = tools.run_decrypt_block(algo, mode, _input)
+ actual_output = tools.run_decrypt_block(algo, mode, _input, use_boxes)
if _assert_output(actual_output, _plaintexts):
return _TestExitCode.SUCCESS
else:
@@ -186,7 +186,7 @@ if __name__ == '__main__':
parser.add_argument('--log', '-l', help='set log file path')
args = parser.parse_args()
- tools = toolkit.Tools(args.path, use_sde=args.sde, use_boxes=args.box)
+ tools = toolkit.Tools(args.path, use_sde=args.sde)
logging_options = {
'format': '%(asctime)s | %(module)s | %(levelname)s | %(message)s',
@@ -216,13 +216,13 @@ if __name__ == '__main__':
mode = maybe_mode
logging.info('Mode: ' + mode)
try:
- exit_codes.append(_run_encryption_tests(tools, algo, mode))
+ exit_codes.append(_run_encryption_tests(tools, algo, mode, use_boxes=args.box))
except Exception as e:
logging.error('Encountered an exception!')
logging.exception(e)
exit_codes.append(_TestExitCode.ERROR)
try:
- exit_codes.append(_run_decryption_tests(tools, algo, mode))
+ exit_codes.append(_run_decryption_tests(tools, algo, mode, use_boxes=args.box))
except Exception as e:
logging.error('Encountered an exception!')
logging.exception(e)