diff options
author | Donald Stufft <donald@stufft.io> | 2013-10-19 19:33:06 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-10-19 19:33:06 -0400 |
commit | 3359d7efdc5e96ae25c69226a2a1452a8f6641f7 (patch) | |
tree | 76aba61b0dd80e2a4bbf5f50077f84bf7fa75e50 | |
parent | 34b6ae71031bdb65e9dc0ac334edd53f1c92d439 (diff) | |
download | cryptography-3359d7efdc5e96ae25c69226a2a1452a8f6641f7.tar.gz cryptography-3359d7efdc5e96ae25c69226a2a1452a8f6641f7.tar.bz2 cryptography-3359d7efdc5e96ae25c69226a2a1452a8f6641f7.zip |
Test what happens when an invalid line is in the cryptrec vectors
-rw-r--r-- | tests/test_utils.py | 14 | ||||
-rw-r--r-- | tests/utils.py | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index a9bb6a87..3fe9e570 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -269,6 +269,20 @@ def test_load_cryptrec_vectors(): ] +def test_load_cryptrec_vectors_invalid(): + vector_data = textwrap.dedent(""" + # Vectors taken from http://info.isl.ntt.co.jp/crypt/eng/camellia/ + # Download is t_camelia.txt + + # Camellia with 128-bit key + + E No.001 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + """).splitlines() + + with pytest.raises(ValueError): + load_cryptrec_vectors(vector_data) + + def test_load_cryptrec_vectors_from_file_encrypt(): test_set = load_cryptrec_vectors_from_file( "Camellia/NTT/camellia-128-ecb.txt" diff --git a/tests/utils.py b/tests/utils.py index 03b780f8..fa7cc68d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -90,6 +90,8 @@ def load_cryptrec_vectors(vector_data): "plaintext": pt, "ciphertext": ct }) + else: + raise ValueError("Invalid line in file '{}'".format(line)) return cryptrec_list |