14
$\begingroup$

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

Wikpedia says these variables are saved.

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – D.W. Mar 6 '13 at 5:11
  • 1
    $\begingroup$ 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. $\endgroup$ – mikeazo Mar 7 '13 at 14:49
  • $\begingroup$ Are you talking about openssl compatible key? Can you give the code? $\endgroup$ – Smit Johnth Mar 7 '13 at 18:17
  • $\begingroup$ To view the details of an RSA key or certificate, use the following command: openssl rsa -in key.pem -text –noout $\endgroup$ – Olis Arinze Oct 29 '17 at 22:45
  • $\begingroup$ This is already mentioned in the accepted answer. $\endgroup$ – Gilles 'SO- stop being evil' Oct 30 '17 at 9:45
18
$\begingroup$

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}$)
$\endgroup$
  • 2
    $\begingroup$ 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? $\endgroup$ – Smit Johnth Apr 26 '13 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.