diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-02-12 23:57:27 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-02-12 23:57:27 -0600 |
commit | 09328bbfb3306d3c7b02a44f12ecd22ce3ec700e (patch) | |
tree | 500b790399084ec51a51cec7d5f0cafcc812bd20 /cryptography/hazmat/primitives/asymmetric/rsa.py | |
parent | 93b37348f1cf2a30a54aa0e4229493d2ff8c108a (diff) | |
download | cryptography-09328bbfb3306d3c7b02a44f12ecd22ce3ec700e.tar.gz cryptography-09328bbfb3306d3c7b02a44f12ecd22ce3ec700e.tar.bz2 cryptography-09328bbfb3306d3c7b02a44f12ecd22ce3ec700e.zip |
add crt coefficients to RSAPrivateKey constructor and update tests
Diffstat (limited to 'cryptography/hazmat/primitives/asymmetric/rsa.py')
-rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index 60c5c807..dbe56b47 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -72,10 +72,14 @@ class RSAPublicKey(object): @utils.register_interface(interfaces.RSAPrivateKey) class RSAPrivateKey(object): - def __init__(self, p, q, private_exponent, public_exponent, modulus): + def __init__(self, p, q, private_exponent, dmp1, dmq1, iqmp, + public_exponent, modulus): if ( not isinstance(p, six.integer_types) or not isinstance(q, six.integer_types) or + not isinstance(dmp1, six.integer_types) or + not isinstance(dmq1, six.integer_types) or + not isinstance(iqmp, six.integer_types) or not isinstance(private_exponent, six.integer_types) or not isinstance(public_exponent, six.integer_types) or not isinstance(modulus, six.integer_types) @@ -91,6 +95,15 @@ class RSAPrivateKey(object): if q >= modulus: raise ValueError("q must be < modulus") + if dmp1 >= modulus: + raise ValueError("dmp1 must be < modulus") + + if dmq1 >= modulus: + raise ValueError("dmq1 must be < modulus") + + if iqmp >= modulus: + raise ValueError("iqmp must be < modulus") + if private_exponent >= modulus: raise ValueError("private_exponent must be < modulus") @@ -100,11 +113,20 @@ class RSAPrivateKey(object): if public_exponent & 1 == 0: raise ValueError("public_exponent must be odd") + if dmp1 & 1 == 0: + raise ValueError("dmp1 must be odd") + + if dmq1 & 1 == 0: + raise ValueError("dmq1 must be odd") + if p * q != modulus: raise ValueError("p*q must equal modulus") self._p = p self._q = q + self._dmp1 = dmp1 + self._dmq1 = dmq1 + self._iqmp = iqmp self._private_exponent = private_exponent self._public_exponent = public_exponent self._modulus = modulus |