diff options
author | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-05-17 22:57:38 +0200 |
---|---|---|
committer | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2012-05-17 22:57:38 +0200 |
commit | 17e5370d948e94135338111363f97cc9d513c92a (patch) | |
tree | 524cc63aa81cb13b4e7f8f8cc0976861a0a5f5a6 | |
parent | 5e78b3f67c62d4df785f2b27eb1ed782d997e558 (diff) | |
download | pycrypto-17e5370d948e94135338111363f97cc9d513c92a.tar.gz |
Added OPENPGP mode to RoundTripTests
-rw-r--r-- | lib/Crypto/SelfTest/Cipher/common.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Crypto/SelfTest/Cipher/common.py b/lib/Crypto/SelfTest/Cipher/common.py index 9afa147..e56fa1b 100644 --- a/lib/Crypto/SelfTest/Cipher/common.py +++ b/lib/Crypto/SelfTest/Cipher/common.py @@ -239,10 +239,16 @@ 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_OFB): + for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP): 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) + + if mode != self.module.MODE_OPENPGP: + decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv) + else: + eiv = ciphertext[:self.module.block_size+2] + ciphertext = ciphertext[self.module.block_size+2:] + decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv) decrypted_plaintext = decryption_cipher.decrypt(ciphertext) self.assertEqual(self.plaintext, decrypted_plaintext) |