diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-02-06 21:06:18 +0000 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-02-06 21:15:47 +0000 |
commit | 4eaab17b738963335c76cfafafee44fef8203dee (patch) | |
tree | dcb0b2f3febd8be901aa80d12fe0e7e7f8a43c9d /cryptography/hazmat/primitives/asymmetric/rsa.py | |
parent | 7d69d3a831abfdfadf014ece0b324d406742d286 (diff) | |
download | cryptography-4eaab17b738963335c76cfafafee44fef8203dee.tar.gz cryptography-4eaab17b738963335c76cfafafee44fef8203dee.tar.bz2 cryptography-4eaab17b738963335c76cfafafee44fef8203dee.zip |
More sanity checks
Diffstat (limited to 'cryptography/hazmat/primitives/asymmetric/rsa.py')
-rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index 3dd88e91..9124757a 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -82,12 +82,21 @@ class RSAPrivateKey(object): if modulus < 3: raise ValueError("modulus must be >= 3") + if p >= modulus: + raise ValueError("p must be < modulus") + + if q >= modulus: + raise ValueError("q must be < modulus") + if private_exponent >= modulus: raise ValueError("private_exponent must be < modulus") if public_exponent < 3 or public_exponent >= modulus: raise ValueError("public_exponent must be >= 3 and < modulus") + if p * q != modulus: + raise ValueError("p*q must equal modulus") + self._p = p self._q = q self._private_exponent = private_exponent |