aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-08-09 07:28:31 -0400
committerDonald Stufft <donald@stufft.io>2013-08-09 07:28:31 -0400
commit5de0392f9be95fcd87db096a3176c172f01009da (patch)
tree5efee649acd6d864b39a8418bf1e97d29326a85f /tests
parent3704a8364daf6f7fa7d6a9298a82bdd2c151eb74 (diff)
downloadcryptography-5de0392f9be95fcd87db096a3176c172f01009da.tar.gz
cryptography-5de0392f9be95fcd87db096a3176c172f01009da.tar.bz2
cryptography-5de0392f9be95fcd87db096a3176c172f01009da.zip
Properly decode plaintext before encrypting it
Diffstat (limited to 'tests')
-rw-r--r--tests/primitives/test_block.py3
-rw-r--r--tests/primitives/test_nist.py45
2 files changed, 32 insertions, 16 deletions
diff --git a/tests/primitives/test_block.py b/tests/primitives/test_block.py
index b976e217..f2da5830 100644
--- a/tests/primitives/test_block.py
+++ b/tests/primitives/test_block.py
@@ -16,5 +16,6 @@ class TestBlockCipher(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
diff --git a/tests/primitives/test_nist.py b/tests/primitives/test_nist.py
index 88090f9a..82620685 100644
--- a/tests/primitives/test_nist.py
+++ b/tests/primitives/test_nist.py
@@ -38,7 +38,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCGFSbox192.rsp")
@@ -47,7 +48,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCGFSbox256.rsp")
@@ -56,7 +58,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCKeySbox128.rsp")
@@ -65,7 +68,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCKeySbox192.rsp")
@@ -74,7 +78,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCKeySbox256.rsp")
@@ -83,7 +88,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarKey128.rsp")
@@ -92,7 +98,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarKey192.rsp")
@@ -101,7 +108,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarKey256.rsp")
@@ -110,7 +118,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarTxt128.rsp")
@@ -119,7 +128,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarTxt192.rsp")
@@ -128,7 +138,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@parameterize_kat_encrypt("CBCVarTxt256.rsp")
@@ -137,7 +148,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@paramterize_mmt_encrypt("CBCMMT128.rsp")
@@ -146,7 +158,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@paramterize_mmt_encrypt("CBCMMT192.rsp")
@@ -155,7 +168,8 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
@paramterize_mmt_encrypt("CBCMMT256.rsp")
@@ -164,5 +178,6 @@ class TestAES_CBC(object):
ciphers.AES(binascii.unhexlify(key)),
modes.CBC(binascii.unhexlify(iv), padding.NoPadding())
)
- actual_ciphertext = cipher.encrypt(plaintext) + cipher.finalize()
+ actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
+ actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext