# 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, 2013 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. Mar 7, 2013 at 14:49
• Are you talking about openssl compatible key? Can you give the code? Mar 7, 2013 at 18:17
• To view the details of an RSA key or certificate, use the following command: openssl rsa -in key.pem -text –noout Oct 29, 2017 at 22:45
• This is already mentioned in the accepted answer. Oct 30, 2017 at 9:45

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? Apr 26, 2013 at 19:55
• The "extra" info is probably saved for performance reasons. We wouldn't want to recompute things over and over for potentially lots of uses of the key. Oct 7, 2020 at 18:57