summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2010-08-26 23:43:01 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2010-08-26 23:48:25 -0400
commit1d68d2b9fdf6edc4cc672fa8f2605e6d7e4f517e (patch)
treefcb59305e28f510a9173c4144537d439490ba694
parent901254f9741f879372ca0105e09b1985c8dd1ef0 (diff)
downloadpycrypto-1d68d2b9fdf6edc4cc672fa8f2605e6d7e4f517e.tar.gz
_slowmath: Compute RSA u parameter when it's not given to RSA.construct
This makes _slowmath behave the same as _fastmath in this regard.
-rw-r--r--lib/Crypto/PublicKey/_slowmath.py5
-rw-r--r--lib/Crypto/SelfTest/PublicKey/test_RSA.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Crypto/PublicKey/_slowmath.py b/lib/Crypto/PublicKey/_slowmath.py
index 05f1e18..5761a83 100644
--- a/lib/Crypto/PublicKey/_slowmath.py
+++ b/lib/Crypto/PublicKey/_slowmath.py
@@ -83,7 +83,10 @@ def rsa_construct(n, e, d=None, p=None, q=None, u=None):
if d is not None: obj.d = d
if p is not None: obj.p = p
if q is not None: obj.q = q
- if u is not None: obj.u = u
+ if u is not None:
+ obj.u = u
+ elif p is not None and q is not None:
+ obj.u = inverse(p, q)
return obj
class _DSAKey(object):
diff --git a/lib/Crypto/SelfTest/PublicKey/test_RSA.py b/lib/Crypto/SelfTest/PublicKey/test_RSA.py
index b5de14f..4c60860 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_RSA.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_RSA.py
@@ -142,6 +142,7 @@ class RSATest(unittest.TestCase):
def test_construct_5tuple(self):
"""RSA (default implementation) constructed key (5-tuple)"""
rsaObj = self.rsa.construct((self.n, self.e, self.d, self.p, self.q))
+ self._check_private_key(rsaObj)
self._check_encryption(rsaObj)
self._check_decryption(rsaObj)
self._check_signing(rsaObj)