-
Notifications
You must be signed in to change notification settings - Fork 1.7k
recover (p, q) given (n, e, d) #1633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note should go after the description IMO.
|
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should 1000 be extrated into a constant so it's obvious what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what we should call this. Ideas? It's the base for the candidate number and the value 1000 means we're willing to perform up to 500 iterations (since a += 2 in the loop)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attempts?
FYI 500 attempts has like a 1 in 1.5 Googol chance of failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does += 2 so 1000 only means 500 attempts. And yeah 2**-500 probability of failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_MAX_ATTEMPTS or something?
On Sun Jan 18 2015 at 12:08:39 PM Paul Kehrer notifications@github.com
wrote:
In src/cryptography/hazmat/primitives/asymmetric/rsa.py
#1633 (diff):
- """
See 8.2.2(i) in Handbook of Applied Cryptography.
- ktot = d * e - 1
The quantity d*e-1 is a multiple of phi(n), even,
and can be represented as t*2^s.
- t = ktot
- while t % 2 == 0:
t = t // 2Cycle through all multiplicative inverses in Zn.
The algorithm is non-deterministic, but there is a 50% chance
any candidate a leads to successful factoring.
See "Digitalized Signatures and Public Key Functions as Intractable
as Factorization", M. Rabin, 1979
- spotted = False
- a = 2
- while not spotted and a < 1000:
It does += 2 so 1000 only means 500 attempts. And yeah 2**-500 probability
of failure.—
Reply to this email directly or view it on GitHub
https://github.com/pyca/cryptography/pull/1633/files#r23134808.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, moved it out and added a comment to explain what it is.
|
Test PASSed. |
|
Test PASSed. |
|
lgtm, will merge assuming tests+coverage |
|
Test PASSed. |
The core function is directly adapted from https://github.com/dlitz/pycrypto/blob/7acba5f3a6ff10f1424c309d0d34d2b713233019/lib/Crypto/PublicKey/_slowmath.py#L100, which is public domain.
Fixes #975