diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-02-07 07:49:17 +0000 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-02-07 07:55:05 +0000 |
commit | a3b85506a5ca19d4469679e2cbc665f423066baf (patch) | |
tree | db55f6e962fae04770880e892ae9271fc85012ee /cryptography/hazmat/primitives/asymmetric/rsa.py | |
parent | e237637231018ce571ab336e9885438902ece99e (diff) | |
download | cryptography-a3b85506a5ca19d4469679e2cbc665f423066baf.tar.gz cryptography-a3b85506a5ca19d4469679e2cbc665f423066baf.tar.bz2 cryptography-a3b85506a5ca19d4469679e2cbc665f423066baf.zip |
Check that public_exponent is odd
Diffstat (limited to 'cryptography/hazmat/primitives/asymmetric/rsa.py')
-rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index 9124757a..1b33eaab 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -43,6 +43,9 @@ class RSAPublicKey(object): if public_exponent < 3 or public_exponent >= modulus: raise ValueError("public_exponent must be >= 3 and < modulus") + if public_exponent & 1 == 0: + raise ValueError("public_exponent must be odd") + self._public_exponent = public_exponent self._modulus = modulus @@ -94,6 +97,9 @@ class RSAPrivateKey(object): if public_exponent < 3 or public_exponent >= modulus: raise ValueError("public_exponent must be >= 3 and < modulus") + if public_exponent & 1 == 0: + raise ValueError("public_exponent must be odd") + if p * q != modulus: raise ValueError("p*q must equal modulus") |