27

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

Wikpedia says these variables are saved.

Smit Johnth
  • 1,681
  • 4
  • 17
  • 27

1 Answers1

42

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}$)
Conrado
  • 6,414
  • 1
  • 29
  • 44
  • 2
    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
  • 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. – Chris H. Oct 07 '20 at 18:57