CVS: crypto/test test_publickey.py,1.3,1.4
"A.M. Kuchling" <[email protected]> Thu, 03 Apr 2003 12:27:45 -0800
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/pycrypto/crypto/test
In directory sc8-pr-cvs1:/tmp/cvs-serv28257
Modified Files:
test_publickey.py
Log Message:
Add test cases for blinding
Index: test_publickey.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/test/test_publickey.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- test_publickey.py 28 Feb 2003 15:24:01 -0000 1.3
+++ test_publickey.py 3 Apr 2003 20:27:41 -0000 1.4
@@ -49,6 +49,27 @@
pubonly=key.publickey()
self.test_bool('pubonly.verify(plaintext, signature)')
+ # Test blinding
+ if key.canblind():
+ if verbose: print ' Blinding test'
+ K=number.getPrime(30, randfunc)
+ B="garbage"
+ blindedtext=key.blind(plaintext, B)
+ signature=key.sign(blindedtext, K)
+ unblindedsignature=(key.unblind(signature[0], B),)
+ self.test_bool('key.verify(plaintext, unblindedsignature)')
+ self.test_val('key.sign(plaintext, K)', unblindedsignature)
+
+ # Change a single bit in the blinding factor
+ badB=B[:-3]+chr( 1 ^ ord(B[-3]) )+B[-3:]
+ badunblindedsignature=(key.unblind(signature[0], badB),)
+ self.test_false('key.verify(badtext, badunblindedsignature)')
+
+ badblindedtext=key.blind(plaintext, badB)
+ badsignature=key.sign(blindedtext, K)
+ badunblindedsignature2=(key.unblind(signature[0], B),)
+ self.test_false('key.verify(badtext, badunblindedsignature2)')
+
def exercise (self, randfunc, pk_mod, verbose=0):
N=256 # Key size, measured in bits
-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb:
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/