set e = 2^16+1 (65537) as per recommendation in Dan Boneh's Twenty Years of Attacks on the RSA Cryptosystem - http://crypto.stanford.edu/~dabo/pubs/papers/RSA-survey.pdf

master
Andy 10 years ago
parent 8221ac6a11
commit 6c3093f41d

@ -99,15 +99,17 @@ print
# 4. Choose an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1; i.e., e and φ(n) are coprime.
print "4. looking for an integer e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1; i.e., e and φ(n) are coprime ..."
e_gcd = 2
print "\nSetting e = 2^16+1 (65537) as per recommendation in\nDan Boneh's Twenty Years of Attacks on the RSA Cryptosystem - http://crypto.stanford.edu/~dabo/pubs/papers/RSA-survey.pdf\n"
#e_gcd = 2
# TOFIX: add smth like --> while (e_gcd != 1) and (e > 3): as e should be > than 3
while e_gcd != 1:
e = random.randint(1, f_n)
e_gcd = gcd(e, f_n)
#while e_gcd != 1:
# e = random.randint(1, f_n)
# e_gcd = gcd(e, f_n)
e = 65537
print "e =", bcolors.CYAN, e, bcolors.ENDC
print
print
# 5. Determine d as d ≡ e^1 (mod φ(n)); i.e., d is the multiplicative inverse of e (modulo φ(n)).
# http://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm#Modular_inverse

Loading…
Cancel
Save