summaryrefslogtreecommitdiff
path: root/lib/Crypto/SelfTest/Cipher
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-14 19:52:30 +0200
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-14 19:52:30 +0200
commit67d8cd1aaf1863cd7510baebbef9b395015312e4 (patch)
tree6bbcdd98516460c033713599b40aa77e8d4eac31 /lib/Crypto/SelfTest/Cipher
parentd946a0aa4ebcc82316a3e42fbb69305e4d44dcd1 (diff)
downloadpycrypto-67d8cd1aaf1863cd7510baebbef9b395015312e4.tar.gz
Removed PGP mode from block ciphers
Diffstat (limited to 'lib/Crypto/SelfTest/Cipher')
-rw-r--r--lib/Crypto/SelfTest/Cipher/common.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Crypto/SelfTest/Cipher/common.py b/lib/Crypto/SelfTest/Cipher/common.py
index af34e97..c48cb7f 100644
--- a/lib/Crypto/SelfTest/Cipher/common.py
+++ b/lib/Crypto/SelfTest/Cipher/common.py
@@ -220,13 +220,26 @@ class RoundtripTest(unittest.TestCase):
return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)
def runTest(self):
- for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_PGP, self.module.MODE_OFB):
+ for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB):
encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
ciphertext = encryption_cipher.encrypt(self.plaintext)
decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
self.assertEqual(self.plaintext, decrypted_plaintext)
+class PGPTest(unittest.TestCase):
+ def __init__(self, module, params):
+ unittest.TestCase.__init__(self)
+ self.module = module
+ self.key = b(params['key'])
+
+ def shortDescription(self):
+ return "MODE_PGP was implemented incorrectly and insecurely. It's completely banished now."
+
+ def runTest(self):
+ self.assertRaises(ValueError, self.module.new, a2b_hex(self.key),
+ self.module.MODE_PGP)
+
def make_block_tests(module, module_name, test_data):
tests = []
extra_tests_added = 0
@@ -272,6 +285,7 @@ def make_block_tests(module, module_name, test_data):
CTRWraparoundTest(module, params),
CFBSegmentSizeTest(module, params),
RoundtripTest(module, params),
+ PGPTest(module, params),
]
extra_tests_added = 1