CVS: crypto/PublicKey DSA.py,1.14,1.15 ElGamal.py,1.8,1.9

"A.M. Kuchling" <[email protected]> Fri, 04 Apr 2003 11:44:30 -0800
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Update of /cvsroot/pycrypto/crypto/PublicKey
In directory sc8-pr-cvs1:/tmp/cvs-serv27459

Modified Files:
	DSA.py ElGamal.py 
Log Message:
Use number.size()

Index: DSA.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/PublicKey/DSA.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DSA.py	4 Apr 2003 15:13:34 -0000	1.14
+++ DSA.py	4 Apr 2003 19:44:25 -0000	1.15
@@ -14,6 +14,7 @@
 __revision__ = "$Id$"
 
 from Crypto.PublicKey.pubkey import *
+from Crypto.Util import number
 from Crypto.Util.number import bytes_to_long, long_to_bytes
 from Crypto.Hash import SHA
 
@@ -143,10 +144,7 @@
 
     def size(self):
         "Return the maximum number of bits that can be handled by this key."
-        bits, power = 0,1L
-        while (power<self.p):
-            bits, power = bits+1, power<<1
-        return bits-1
+        return number.size(self.p) - 1
 
     def has_private(self):
         """Return a Boolean denoting whether the object contains

Index: ElGamal.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/PublicKey/ElGamal.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ElGamal.py	4 Apr 2003 15:13:35 -0000	1.8
+++ ElGamal.py	4 Apr 2003 19:44:26 -0000	1.9
@@ -13,6 +13,7 @@
 __revision__ = "$Id$"
 
 from Crypto.PublicKey.pubkey import *
+from Crypto.Util import number
 
 class error (Exception):
     pass
@@ -113,9 +114,7 @@
 
     def size(self):
         "Return the maximum number of bits that can be handled by this key."
-        bits, power = 0,1L
-        while (power<self.p): bits, power = bits+1, power<<1
-        return bits-1
+        return number.size(self.p) - 1
 
     def has_private(self):
         """Return a Boolean denoting whether the object contains



-------------------------------------------------------
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/