diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-29 18:20:17 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-29 18:20:17 +0200 |
commit | a5487826a1f28952a560c50f14e284c4292d94ca (patch) | |
tree | 3734791d7c65ded746a4187f1d1d4d3339087e97 /rsa/key.py | |
parent | fec61ece4c1593e79bc52c84cf69a715cd6a9dcd (diff) | |
download | rsa-git-a5487826a1f28952a560c50f14e284c4292d94ca.tar.gz |
Introduced NotRelativePrimeError exception.
This makes catching exceptions slightly stronger, as it is now possible
to check for this specific exception. Furthermore, information about the
not-prime numbers is included in the exception object.
Diffstat (limited to 'rsa/key.py')
-rw-r--r-- | rsa/key.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -666,9 +666,11 @@ def calculate_keys_custom_exponent(p, q, exponent): try: d = rsa.common.inverse(exponent, phi_n) - except ValueError: - raise ValueError("e (%d) and phi_n (%d) are not relatively prime" % - (exponent, phi_n)) + except rsa.common.NotRelativePrimeError as ex: + raise rsa.common.NotRelativePrimeError( + exponent, phi_n, ex.d, + msg="e (%d) and phi_n (%d) are not relatively prime (divider=%i)" % + (exponent, phi_n, ex.d)) if (exponent * d) % phi_n != 1: raise ValueError("e (%d) and d (%d) are not mult. inv. modulo " |