summaryrefslogtreecommitdiff
path: root/rsa/key.py
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2016-01-27 14:53:42 +0100
committerSybren A. Stüvel <sybren@stuvel.eu>2016-01-27 14:53:42 +0100
commit417ec0d7081ddcd94e31be2741d5b63600a3fe53 (patch)
tree549cc1b183c86d9fe9c24b31a40f176b49f8dae5 /rsa/key.py
parent7d818018d62d78d295bc4d80f7f2a6b6d4572b2a (diff)
downloadrsa-git-417ec0d7081ddcd94e31be2741d5b63600a3fe53.tar.gz
Fixed bug where PrivateKey.exp2 wasn't correctly processed in the constructor.
If exp1 was not given and exp2 was, it would still recompute exp2 instead of using the passed value.
Diffstat (limited to 'rsa/key.py')
-rw-r--r--rsa/key.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/rsa/key.py b/rsa/key.py
index 6014709..c1931fc 100644
--- a/rsa/key.py
+++ b/rsa/key.py
@@ -301,13 +301,13 @@ class PrivateKey(AbstractKey):
>>> PrivateKey(3247, 65537, 833, 191, 17)
PrivateKey(3247, 65537, 833, 191, 17)
- exp1, exp2 and coef don't have to be given, they will be calculated:
+ exp1, exp2 and coef can be given, but if None or omitted they will be calculated:
- >>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
+ >>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287, exp2=4)
>>> pk.exp1
55063
- >>> pk.exp2
- 10095
+ >>> pk.exp2 # this is of course not a correct value, but it is the one we passed.
+ 4
>>> pk.coef
50797
@@ -337,7 +337,7 @@ class PrivateKey(AbstractKey):
else:
self.exp1 = exp1
- if exp1 is None:
+ if exp2 is None:
self.exp2 = int(d % (q - 1))
else:
self.exp2 = exp2