diff options
author | Donald Stufft <donald@stufft.io> | 2013-09-10 20:24:20 -0700 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2013-09-10 20:24:20 -0700 |
commit | 9287c2344c6c91ad838a251d3b6fde2a6ea88b56 (patch) | |
tree | ee0d0161e0b8856385e0762653f610b2f36bc851 /tests | |
parent | a672bbe6226648c68cdb628b5b7d67f2e8270698 (diff) | |
parent | c507412ec09e6fa502fbd8587824901e1cf9a935 (diff) | |
download | cryptography-9287c2344c6c91ad838a251d3b6fde2a6ea88b56.tar.gz cryptography-9287c2344c6c91ad838a251d3b6fde2a6ea88b56.tar.bz2 cryptography-9287c2344c6c91ad838a251d3b6fde2a6ea88b56.zip |
Merge pull request #57 from reaperhulk/ofb-support
Output feedback mode support + test vectors (aes)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/primitives/test_nist.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/primitives/test_nist.py b/tests/primitives/test_nist.py index 3dc8277a..0e16cc9c 100644 --- a/tests/primitives/test_nist.py +++ b/tests/primitives/test_nist.py @@ -133,3 +133,50 @@ class TestAES_ECB(object): actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() assert binascii.hexlify(actual_ciphertext) == ciphertext + + +class TestAES_OFB(object): + @parameterize_encrypt_test( + "AES", "KAT", + ("key", "iv", "plaintext", "ciphertext"), + [ + "OFBGFSbox128.rsp", + "OFBGFSbox192.rsp", + "OFBGFSbox256.rsp", + "OFBKeySbox128.rsp", + "OFBKeySbox192.rsp", + "OFBKeySbox256.rsp", + "OFBVarKey128.rsp", + "OFBVarKey192.rsp", + "OFBVarKey256.rsp", + "OFBVarTxt128.rsp", + "OFBVarTxt192.rsp", + "OFBVarTxt256.rsp", + ] + ) + def test_KAT(self, key, iv, plaintext, ciphertext): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(key)), + modes.OFB(binascii.unhexlify(iv)) + ) + actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) + actual_ciphertext += cipher.finalize() + assert binascii.hexlify(actual_ciphertext) == ciphertext + + @parameterize_encrypt_test( + "AES", "MMT", + ("key", "iv", "plaintext", "ciphertext"), + [ + "OFBMMT128.rsp", + "OFBMMT192.rsp", + "OFBMMT256.rsp", + ] + ) + def test_MMT(self, key, iv, plaintext, ciphertext): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(key)), + modes.OFB(binascii.unhexlify(iv)) + ) + actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) + actual_ciphertext += cipher.finalize() + assert binascii.hexlify(actual_ciphertext) == ciphertext |