diff options
Diffstat (limited to 'tests/test_utils.py')
| -rw-r--r-- | tests/test_utils.py | 116 | 
1 files changed, 111 insertions, 5 deletions
| diff --git a/tests/test_utils.py b/tests/test_utils.py index 0692c8d1..457cd869 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -62,7 +62,19 @@ def test_load_nist_vectors_encrypt():      PLAINTEXT = 9798c4640bad75c7c3227db910174e72      """).splitlines() -    assert load_nist_vectors(vector_data, "ENCRYPT") == [ +    assert load_nist_vectors(vector_data) == [ +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", +            "ciphertext": b"0336763e966d92595a567cc9ce537f5e", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"9798c4640bad75c7c3227db910174e72", +            "ciphertext": b"a9a1631bf4996954ebc093957b234589", +        },          {              "key": b"00000000000000000000000000000000",              "iv": b"00000000000000000000000000000000", @@ -116,7 +128,19 @@ def test_load_nist_vectors_decrypt():      PLAINTEXT = 9798c4640bad75c7c3227db910174e72      """).splitlines() -    assert load_nist_vectors(vector_data, "DECRYPT") == [ +    assert load_nist_vectors(vector_data) == [ +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", +            "ciphertext": b"0336763e966d92595a567cc9ce537f5e", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"9798c4640bad75c7c3227db910174e72", +            "ciphertext": b"a9a1631bf4996954ebc093957b234589", +        },          {              "key": b"00000000000000000000000000000000",              "iv": b"00000000000000000000000000000000", @@ -134,8 +158,7 @@ def test_load_nist_vectors_decrypt():  def test_load_nist_vectors_from_file_encrypt():      assert load_nist_vectors_from_file( -        os.path.join("ciphers", "AES", "CBC", "CBCGFSbox128.rsp"), -        "ENCRYPT" +        os.path.join("ciphers", "AES", "CBC", "CBCGFSbox128.rsp")      ) == [          {              "key": b"00000000000000000000000000000000", @@ -179,13 +202,54 @@ def test_load_nist_vectors_from_file_encrypt():              "plaintext": b"58c8e00b2631686d54eab84b91f0aca1",              "ciphertext": b"08a4e2efec8a8e3312ca7460b9040bbf",          }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", +            "ciphertext": b"0336763e966d92595a567cc9ce537f5e", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"9798c4640bad75c7c3227db910174e72", +            "ciphertext": b"a9a1631bf4996954ebc093957b234589", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"96ab5c2ff612d9dfaae8c31f30c42168", +            "ciphertext": b"ff4f8391a6a40ca5b25d23bedd44a597", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"6a118a874519e64e9963798a503f1d35", +            "ciphertext": b"dc43be40be0e53712f7e2bf5ca707209", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"cb9fceec81286ca3e989bd979b0cb284", +            "ciphertext": b"92beedab1895a94faa69b632e5cc47ce", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"b26aeb1874e47ca8358ff22378f09144", +            "ciphertext": b"459264f4798f6a78bacb89c15ed3d601", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"58c8e00b2631686d54eab84b91f0aca1", +            "ciphertext": b"08a4e2efec8a8e3312ca7460b9040bbf", +        },      ]  def test_load_nist_vectors_from_file_decrypt():      assert load_nist_vectors_from_file(          os.path.join("ciphers", "AES", "CBC", "CBCGFSbox128.rsp"), -        "DECRYPT",      ) == [          {              "key": b"00000000000000000000000000000000", @@ -229,6 +293,48 @@ def test_load_nist_vectors_from_file_decrypt():              "plaintext": b"58c8e00b2631686d54eab84b91f0aca1",              "ciphertext": b"08a4e2efec8a8e3312ca7460b9040bbf",          }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", +            "ciphertext": b"0336763e966d92595a567cc9ce537f5e", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"9798c4640bad75c7c3227db910174e72", +            "ciphertext": b"a9a1631bf4996954ebc093957b234589", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"96ab5c2ff612d9dfaae8c31f30c42168", +            "ciphertext": b"ff4f8391a6a40ca5b25d23bedd44a597", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"6a118a874519e64e9963798a503f1d35", +            "ciphertext": b"dc43be40be0e53712f7e2bf5ca707209", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"cb9fceec81286ca3e989bd979b0cb284", +            "ciphertext": b"92beedab1895a94faa69b632e5cc47ce", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"b26aeb1874e47ca8358ff22378f09144", +            "ciphertext": b"459264f4798f6a78bacb89c15ed3d601", +        }, +        { +            "key": b"00000000000000000000000000000000", +            "iv": b"00000000000000000000000000000000", +            "plaintext": b"58c8e00b2631686d54eab84b91f0aca1", +            "ciphertext": b"08a4e2efec8a8e3312ca7460b9040bbf", +        },      ] | 
