# What data is saved in RSA private key?

What data is saved in RSA private key in openssl? How to view it?

Wikpedia says these variables are saved.

-
I'm not sure I understand the question. Perhaps you could elaborate a bit. What are you trying to accomplish? Why do you want to know? How will you use the answer? Some information on those sorts of topics might increase the odds that we can offer an answer that will be useful to you. –  D.W. Mar 6 '13 at 5:11
How to view it will greatly depend on how the private key is encoded. That said, I have often had success reading the private key certificate into Java and then accessing the info from there. –  mikeazo Mar 7 '13 at 14:49
Are you talking about openssl compatible key? Can you give the code? –  Smit Johnth Mar 7 '13 at 18:17

You can print the data with (change PEM to DER if required):

openssl rsa -in Alice.key -text -inform PEM -noout

The following data is stored:

• Modulus ($n = pq$)
• Public exponent ($e$)
• Private exponent ($d = e^{-1} \pmod{\phi{(n)}}$)
• First prime ($p$)
• Second prime ($q$)
• First exponent, used for Chinese remainder theorem ($d_P = d \pmod{p - 1}$)
• Second exponent, used for CRT ($d_Q = d \pmod{q - 1}$)
• Coefficient, used for CRT ($q_{\mathrm{inv}} = q^{-1} \pmod{p}$)
-
That works :) Somehow I haven't got a notification or haven't noticed it. Why is all this data saved? Is it not enough to save just p, q, e and probably d? What are first and second exponent used for? Is there any integrity check performed to verify that these variables are consistent? –  Smit Johnth Apr 26 '13 at 19:55

e ∈ {1,2, . . . ,Φ(n)−1} and gcd(e,Φ(n)) = 1.

in addition Φ(n) = (p−1)(q−1) and n = p * q

and then compute: d*e ≡ 1 modΦ(n)

For Instance that might me this value:

This answer looks erroneous to me. $e=1$ gives no security. $e=2$ is not RSA. From memory, and this, $e$ in OpenSSL can't be more than 65537 without breaking compatibility with some implementations, and is almost always 65537 (lower value are not FIPS-conformant). Also from memory, and that, the private key is usually in full PKCS#1 format, including dP, dQ, qInv. Also the right equation (at least in PKCS#1) is $d⋅e≡1\pmod{\operatorname{lcm}(p-1,q-1)}$. –  fgrieu Apr 6 '13 at 10:38