summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-03 19:10:11 +0200
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2012-05-03 19:10:11 +0200
commit5b199b0b7b3b692997e3c70851ecac87a7da4731 (patch)
tree11238015e54bc1ec82acc00d274e994cf4c92904
parentffe841f104d882fa294c9d6e928e334014a19656 (diff)
downloadpycrypto-5b199b0b7b3b692997e3c70851ecac87a7da4731.tar.gz
Add negative test for signature verification.
Verify that Elgamal signature works with longs (it was disabled by mistake).
-rw-r--r--lib/Crypto/SelfTest/PublicKey/test_ElGamal.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
index e0bac33..d199fee 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_ElGamal.py
@@ -119,7 +119,7 @@ class ElGamalTest(unittest.TestCase):
def test_signing(self):
for tv in self.tvs:
for as_longs in (0,1):
- d = self.convert_tv(tv, 0)
+ d = self.convert_tv(tv, as_longs)
key = ElGamal.construct(d['key'])
sig1, sig2 = key.sign(d['h'], d['k'])
self.assertEquals(sig1, d['sig1'])
@@ -128,10 +128,14 @@ class ElGamalTest(unittest.TestCase):
def test_verification(self):
for tv in self.tvs:
for as_longs in (0,1):
- d = self.convert_tv(tv, 0)
+ d = self.convert_tv(tv, as_longs)
key = ElGamal.construct(d['key'])
+ # Positive test
res = key.verify( d['h'], (d['sig1'],d['sig2']) )
self.assertTrue(res)
+ # Negative test
+ res = key.verify( d['h'], (d['sig1']+1,d['sig2']) )
+ self.assertFalse(res)
def convert_tv(self, tv, as_longs=0):
"""Convert a test vector from textual form (hexadecimal ascii