For RSA, how do i calculate the secret exponent?
Given p and q the two primes, and phi=(p-1)(q-1), and the public exponent (0x10001), how do i get the secret exponent 'd' ?
I've read that i have to do: d = e-1 mod phi using modular inversion and the euclidean equation but i cannot understand how the above formula maps to either the a-1 ≡ x mod m formula on the modular inversion wiki page, or how it maps to the euclidean GCD equation.
Can someone help please, cheers
You can use the extended Euclidean algorithm to solve for
d
in the congruenceFor RSA encryption,
e
is the encryption key,d
is the decryption key, and encryption and decryption are both performed by exponentiation modm
. If you encrypt a messagea
with keye
, and then decrypt it using keyd
, you calculate (ae)d = ade modm
. But sincede = 1 mod phi(m)
, Euler's totient theorem tells us that ade is congruent to a1 mod m -- in other words, you get back the originala
.There are no known efficient ways to obtain the decryption key
d
knowing only the encryption keye
and the modulusm
, without knowing the factorizationm = pq
, so RSA encryption is believed to be secure.