CVS: crypto/PublicKey DSA.py,1.11,1.12 RSA.py,1.11,1.12

"A.M. Kuchling" <[email protected]> Thu, 03 Apr 2003 10:19:11 -0800
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Update of /cvsroot/pycrypto/crypto/PublicKey
In directory sc8-pr-cvs1:/tmp/cvs-serv6079

Modified Files:
	DSA.py RSA.py 
Log Message:
Use _fastmath module

Index: DSA.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/PublicKey/DSA.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DSA.py	28 Feb 2003 15:25:06 -0000	1.11
+++ DSA.py	3 Apr 2003 18:19:03 -0000	1.12
@@ -18,9 +18,9 @@
 from Crypto.Hash import SHA
 
 try:
-    from Crypto.PublicKey import _dsa
-except:
-    _dsa = None
+    from Crypto.PublicKey import _fastmath
+except ImportError:
+    _fastmath = None
 
 class error (Exception):
     pass
@@ -178,10 +178,10 @@
     def __setstate__(self, state):
         y,g,p,q = state['y'], state['g'], state['p'], state['q']
         if 'x' not in state:
-            self.key = _dsa.construct(y,g,p,q)
+            self.key = _fastmath.dsa_construct(y,g,p,q)
         else:
             x = state['x']
-            self.key = _dsa.construct(y,g,p,q,x)
+            self.key = _fastmath.dsa_construct(y,g,p,q,x)
 
     def _sign(self, M, K):
         return self.key._sign(M, K)
@@ -210,11 +210,11 @@
     return construct_c((y,g,p,q,x))
 
 def construct_c(tuple):
-    key = apply(_dsa.construct, tuple)
+    key = apply(_fastmath.dsa_construct, tuple)
     return DSAobj_c(key)
 
-if _dsa:
+if _fastmath:
     #print "using C version of DSA"
     generate = generate_c
     construct = construct_c
-    error = _dsa.error
+    error = _fastmath.error

Index: RSA.py
===================================================================
RCS file: /cvsroot/pycrypto/crypto/PublicKey/RSA.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- RSA.py	28 Feb 2003 15:25:09 -0000	1.11
+++ RSA.py	3 Apr 2003 18:19:05 -0000	1.12
@@ -15,9 +15,9 @@
 from Crypto.PublicKey import pubkey
 
 try:
-    from Crypto.PublicKey import _rsa
-except:
-    _rsa = None
+    from Crypto.PublicKey import _fastmath
+except ImportError:
+    _fastmath = None
 
 class error (Exception):
     pass
@@ -130,14 +130,14 @@
     def __setstate__(self, state):
         n,e = state['n'], state['e']
         if 'd' not in state:
-            self.key = _rsa.construct(n,e)
+            self.key = _fastmath.rsa_construct(n,e)
         else:
             d = state['d']
             if 'q' not in state:
-                self.key = _rsa.construct(n,e,d)
+                self.key = _fastmath.rsa_construct(n,e,d)
             else:
                 p, q = state['p'], state['q']
-                self.key = _rsa.construct(n,e,d,p,q)
+                self.key = _fastmath.rsa_construct(n,e,d,p,q)
 
     def _encrypt(self, plain, K):
         return (self.key._encrypt(plain),)
@@ -175,11 +175,11 @@
     e=pubkey.getPrime(17, randfunc)
     if progress_func: progress_func('d\n')
     d=pubkey.inverse(e, (p-1)*(q-1))
-    key = _rsa.construct(n,e,d,p,q)
+    key = _fastmath.rsa_construct(n,e,d,p,q)
     return RSAobj_c(key)
 
 def construct_c(tuple):
-    key = apply(_rsa.construct, tuple)
+    key = apply(_fastmath.rsa_construct, tuple)
     return RSAobj_c(key)
 
 object = RSAobj
@@ -187,8 +187,8 @@
 generate_py = generate
 construct_py = construct
 
-if _rsa:
+if _fastmath:
     #print "using C version of RSA"
     generate = generate_c
     construct = construct_c
-    error = _rsa.error
+    error = _fastmath.error



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