# 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

## 2 Answers

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:

p=0DFD2C2A288ACEBC705EFAB30E4447541A8C5A47A37185C5A9CB98389CE4DE19199AA3069B404FD98C801568CB9170EB712BF10B4955CE9C9DC8CE6855C6123h Q=EBE0FCF21866FD9A9F0D72F7994875A8D92E67AEE4B515136B2A778A8048B149828AEA30BD0BA34B977982A3D42168F594CA99F3981DDABFAB2369F229640115h n=F33188211FDF6052BDBB1A37235E0ABB5978A45C71FD381A91AD12FC76DA0544C47568AC83D855D47CA8D8A779579AB72E635D0B0AAAC22D28341E998E90F82122A2C06090F43A37E0203C2B72E401FD06890EC8EAD4F07E686E906F01B2468AE7B30CBD670255C1FEDE1A2762CF4392C0759499CC0ABECFF008728D9A11ADFh e=40B028E1E4CCF07537643101FF72444A0BE1D7682F1EDB553E3AB4F6DD8293CA1945DB12D796AE9244D60565C2EB692A89B8881D58D278562ED60066DD8211E67315CF89857167206120405B08B54D10D4EC4ED4253C75FA74098FE3F7FB751FF5121353C554391E114C85B56A9725E9BD5685D6C9C7EED8EE442366353DC39h d=C21A93EE751A8D4FBFD77285D79D6768C58EBF283743D2889A395F266C78F4A28E86F545960C2CE01EB8AD5246905163B28D0B8BAABB959CC03F4EC499186168AE9ED6D88058898907E61C7CCCC584D65D801CFE32DFC983707F87F5AA6AE4B9E77B9CE630E2C0DF05841B5E4984D059A35D7270D500514891F7B77B804BED81h

-
It's not an answer for "how can i view them?". – Smit Johnth Mar 7 '13 at 13:40
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
That doesn't answer the question at all. – Paŭlo Ebermann Apr 6 '13 at 17:37