diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2009-10-08 20:26:33 -0400 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2009-10-08 20:30:45 -0400 |
commit | 215a7d3c2cb4461e8175bb2b6cc8362d89c33dfe (patch) | |
tree | 48305768302fd745819f1c8dcf22299120745945 | |
parent | 02e3976a18bb08e13464184b702ddeebd5c8b74b (diff) | |
download | pycrypto-215a7d3c2cb4461e8175bb2b6cc8362d89c33dfe.tar.gz |
Add self-test for pubkey == and != operator overloading
-rw-r--r-- | lib/Crypto/SelfTest/PublicKey/test_DSA.py | 4 | ||||
-rw-r--r-- | lib/Crypto/SelfTest/PublicKey/test_RSA.py | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Crypto/SelfTest/PublicKey/test_DSA.py b/lib/Crypto/SelfTest/PublicKey/test_DSA.py index f06eb8d..208a044 100644 --- a/lib/Crypto/SelfTest/PublicKey/test_DSA.py +++ b/lib/Crypto/SelfTest/PublicKey/test_DSA.py @@ -152,6 +152,10 @@ class DSATest(unittest.TestCase): # Public-only key objects should raise an error when .sign() is called self.assertRaises(TypeError, dsaObj.sign, m_hash, k) + # Check __eq__ and __ne__ + self.assert_(dsaObj.publickey() == dsaObj.publickey()) + self.assert_(not (dsaObj.publickey() != dsaObj.publickey())) + def _test_signing(self, dsaObj): k = a2b_hex(self.k) m_hash = a2b_hex(self.m_hash) diff --git a/lib/Crypto/SelfTest/PublicKey/test_RSA.py b/lib/Crypto/SelfTest/PublicKey/test_RSA.py index 03cfe65..66dbe6f 100644 --- a/lib/Crypto/SelfTest/PublicKey/test_RSA.py +++ b/lib/Crypto/SelfTest/PublicKey/test_RSA.py @@ -211,6 +211,10 @@ class RSATest(unittest.TestCase): self.assertRaises(TypeError, rsaObj.sign, ciphertext, "") self.assertRaises(TypeError, rsaObj.decrypt, ciphertext) + # Check __eq__ and __ne__ + self.assert_(rsaObj.publickey() == rsaObj.publickey()) + self.assert_(not (rsaObj.publickey() != rsaObj.publickey())) + def _exercise_primitive(self, rsaObj): # Since we're using a randomly-generated key, we can't check the test # vector, but we can make sure encryption and decryption are inverse |