Skip to content

Commit 417ec0d

Browse files
committed
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.
1 parent 7d81801 commit 417ec0d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

rsa/key.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,13 @@ class PrivateKey(AbstractKey):
301301
>>> PrivateKey(3247, 65537, 833, 191, 17)
302302
PrivateKey(3247, 65537, 833, 191, 17)
303303
304-
exp1, exp2 and coef don't have to be given, they will be calculated:
304+
exp1, exp2 and coef can be given, but if None or omitted they will be calculated:
305305
306-
>>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287)
306+
>>> pk = PrivateKey(3727264081, 65537, 3349121513, 65063, 57287, exp2=4)
307307
>>> pk.exp1
308308
55063
309-
>>> pk.exp2
310-
10095
309+
>>> pk.exp2 # this is of course not a correct value, but it is the one we passed.
310+
4
311311
>>> pk.coef
312312
50797
313313
@@ -337,7 +337,7 @@ def __init__(self, n, e, d, p, q, exp1=None, exp2=None, coef=None):
337337
else:
338338
self.exp1 = exp1
339339

340-
if exp1 is None:
340+
if exp2 is None:
341341
self.exp2 = int(d % (q - 1))
342342
else:
343343
self.exp2 = exp2

0 commit comments

Comments
 (0)