diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-09-10 18:57:35 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-09-10 18:57:35 -0700 |
commit | c9e91e8cc1d8a5e20ec4541328afabe5d633228b (patch) | |
tree | 86754f5dd74324ae18fbc2ed9fca80d0052286ac /tests | |
parent | 180606f3e7fd9083567e9754fca39e44b5b06b15 (diff) | |
parent | 7d9e0d9af5343aea7b4b949c20635ed414238927 (diff) | |
download | cryptography-c9e91e8cc1d8a5e20ec4541328afabe5d633228b.tar.gz cryptography-c9e91e8cc1d8a5e20ec4541328afabe5d633228b.tar.bz2 cryptography-c9e91e8cc1d8a5e20ec4541328afabe5d633228b.zip |
Merge pull request #53 from reaperhulk/ecb-support-im-sorry
ECB Support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bindings/test_openssl.py | 2 | ||||
-rw-r--r-- | tests/primitives/test_nist.py | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/bindings/test_openssl.py b/tests/bindings/test_openssl.py index 1579f002..b23c4ccc 100644 --- a/tests/bindings/test_openssl.py +++ b/tests/bindings/test_openssl.py @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cryptography.bindings.openssl import api +from cryptography.bindings.openssl.api import api class TestOpenSSL(object): diff --git a/tests/primitives/test_nist.py b/tests/primitives/test_nist.py index 8bef118e..3dc8277a 100644 --- a/tests/primitives/test_nist.py +++ b/tests/primitives/test_nist.py @@ -86,3 +86,50 @@ class TestAES_CBC(object): actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() assert binascii.hexlify(actual_ciphertext) == ciphertext + + +class TestAES_ECB(object): + @parameterize_encrypt_test( + "AES", "KAT", + ("key", "plaintext", "ciphertext"), + [ + "ECBGFSbox128.rsp", + "ECBGFSbox192.rsp", + "ECBGFSbox256.rsp", + "ECBKeySbox128.rsp", + "ECBKeySbox192.rsp", + "ECBKeySbox256.rsp", + "ECBVarKey128.rsp", + "ECBVarKey192.rsp", + "ECBVarKey256.rsp", + "ECBVarTxt128.rsp", + "ECBVarTxt192.rsp", + "ECBVarTxt256.rsp", + ] + ) + def test_KAT(self, key, plaintext, ciphertext): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(key)), + modes.ECB() + ) + actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) + actual_ciphertext += cipher.finalize() + assert binascii.hexlify(actual_ciphertext) == ciphertext + + @parameterize_encrypt_test( + "AES", "MMT", + ("key", "plaintext", "ciphertext"), + [ + "ECBMMT128.rsp", + "ECBMMT192.rsp", + "ECBMMT256.rsp", + ] + ) + def test_MMT(self, key, plaintext, ciphertext): + cipher = BlockCipher( + ciphers.AES(binascii.unhexlify(key)), + modes.ECB() + ) + actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) + actual_ciphertext += cipher.finalize() + assert binascii.hexlify(actual_ciphertext) == ciphertext |