aboutsummaryrefslogtreecommitdiffstats
path: root/tests/primitives/test_nist.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-09-09 19:04:16 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-09-09 19:04:16 -0700
commit9f44cabb5010742226e3b429d450fd0b31d020d2 (patch)
tree83826f7e96c80ae365faaa926c19c234a28f7c14 /tests/primitives/test_nist.py
parentf4bb6d3bed87e84f98b7bc35b7f8ed4999c99698 (diff)
downloadcryptography-9f44cabb5010742226e3b429d450fd0b31d020d2.tar.gz
cryptography-9f44cabb5010742226e3b429d450fd0b31d020d2.tar.bz2
cryptography-9f44cabb5010742226e3b429d450fd0b31d020d2.zip
Write out the initial test cases, they don't even fail properly because the 3DES cases look different from the AES ones
Diffstat (limited to 'tests/primitives/test_nist.py')
-rw-r--r--tests/primitives/test_nist.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/primitives/test_nist.py b/tests/primitives/test_nist.py
index 65d130ad..50aee310 100644
--- a/tests/primitives/test_nist.py
+++ b/tests/primitives/test_nist.py
@@ -78,3 +78,43 @@ class TestAES_CBC(object):
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
+
+
+class TestTripleDES_CBC(object):
+ @parameterize_encrypt_test("3DES", "KAT", [
+ "TCBCIinvperm.rsp",
+ "TCBCIpermop.rsp",
+ "TCBCIsubtab.rsp",
+ "TCBCIvarkey.rsp",
+ "TCBCIvartext.rsp",
+ "TCBCinvperm.rsp",
+ "TCBCpermop.rsp",
+ "TCBCsubtab.rsp",
+ "TCBCvarkey.rsp",
+ "TCBCvartext.rsp",
+ ])
+ def test_KAT(self, key, iv, plaintext, ciphertext):
+ cipher = BlockCipher(
+ ciphers.TripleDES(binascii.unhexlify(key)),
+ modes.CBC(binascii.unhexlify(iv))
+ )
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
+ assert binascii.hexlify(actual_ciphertext) == ciphertext
+
+ @parameterize_encrypt_test("3DES", "MMT", [
+ "TCBCIMMT1.rsp",
+ "TCBCIMMT2.rsp",
+ "TCBCIMMT3.rsp",
+ "TCBCMMT1.rsp",
+ "TCBCMMT2.rsp",
+ "TCBCMMT3.rsp",
+ ])
+ def test_MMT(self, key, iv, plaintext, ciphertext):
+ cipher = BlockCipher(
+ ciphers.TripleDES(binascii.unhexlify(key)),
+ modes.CBC(binascii.unhexlify(iv))
+ )
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
+ assert binascii.hexlify(actual_ciphertext) == ciphertext