As far as I can see, generating a private key from two prime numbers p
and q
, having calculated n = pq
, starts with calculating λ(n) = lcm(p-1, q-1)
. This is the detailed explanation given in the wikipedia article for RSA, it's also the implementation I've found in most Python cryptography libraries, and, searching through the openssl source code, it's also how they seem to do it, so I'd say this looks like the standard.
So my question is, why do some implementations appear to use Ï(n)
instead, which is simply (p-1)(q-1)
? I understand that you can calculate λ(n) = Ï(n) / gcd(p-1, q-1)
, so I suppose these two can be equal if p-1 and q-1 are coprime, but what's with the two different implementations?
This way to generate the "private modulo" is used for example in the somewhat popular python program rsatool, it's also mentioned in this popular article detailing how RSA keys are generated, but my problem is, taking the two same prime numbers p
and q
, these two methods will not generate the same private key, so assuming the former is the proper, standard way, where did this other one come from?