What exactly is inside a private key?

May sound stupid to many, but I would like to have some pointers on what exactly is contained inside a private key. I have decent understanding of public/private keys/certificates (have created them many times) and their purpose but would like to take a step back and see what is inside them using a "dump" utility or something - Would I be able to see big prime numbers etc contained inside the private key?

Is there a utility to show me the "logical content" of the output of the following command as opposed to a bunch of ASCII characters?

openssl genrsa


generates

-----BEGIN RSA PRIVATE KEY-----
…
-----END RSA PRIVATE KEY-----


Any pointers appreciated. Same question also applies to the public key btw..

-
Try the pkey option. –  rath Dec 16 '13 at 23:16
thx rath for the pointer. The following command worked for me. . . openssl rsa -in privkey.pem -text –  user1813603 Dec 16 '13 at 23:37
Good to know. May I suggest that you write an answer showing how the RSA key components get displayed? –  rath Dec 16 '13 at 23:59
This question appears to be off-topic because it is about using openssl and the format it uses, rather than about the cryptographic keys themselves. It would be on-topic on Unix & Linux. –  Gilles Dec 19 '13 at 19:24

\$ openssl genrsa | openssl rsa -text -noout
Private-Key: (512 bit)
modulus:
00:e7:be:c0:b7:7a:8a:e6:58:c3:dc:3e:eb:ed:bc:
a7:15:04:78:8d:9d:fe:a2:83:aa:ca:85:5f:4b:ae:
5c:fa:3d:bd:2b:a9:91:58:e1:da:d8:8a:bd:25:6d:
07:10:74:52:2f:ee:ce:bd:3c:c6:89:01:2e:ff:9a:
3b:61:4d:e7:81
publicExponent: 65537 (0x10001)
privateExponent:
00:8d:b9:23:44:51:e5:c6:0e:fc:e0:a1:7e:49:2a:
79:07:aa:6f:4b:34:17:38:2d:cb:72:04:f4:8d:64:
f9:a9:72:94:30:6e:d8:65:81:e7:be:05:a8:19:fb:
cd:b3:d2:c8:41
prime1:
00:fc:ea:3f:dd:a9:5f:6f:4d:05:41:50:04:81:8e:
c7:6b:a0:95:d3:d4:36:09:73:b4:b8:06:db:fc:f2:
89:0c:e9
prime2:
00:ea:92:65:f9:06:58:11:f4:bc:fe:e6:10:0b:80:
51:73:18:1b:91:24:27:83:ab:c9:b3:4c:79:01:1f:
60:86:d9
exponent1:
00:e6:7b:63:30:51:c5:d2:dc:51:c9:af:6e:2b:d3:
3e:10:eb:0b:1f:3b:e8:f2:bc:2b:18:f9:c7:48:c0:
8d:fc:e1
exponent2:
11:b3:04:30:bb:12:d0:20:08:56:af:63:4c:8a:dd:
1a:73:1a:39:64:61:fa:e4:6e:6e:b1:f9:7b:65:33:
b2:59
coefficient:
3a:6d:f6:8f:4b:d2:c3:a8:53:aa:32:0d:b9:c5:50:
d8:db:9c:e3:9b:a8:40:c3:c0:14:2b:7e:67:25:67:
b7:03


The numbers are in hexadecimal with a funny format, except for the public exponents. You can convert them to your favorite format with a bit of text processing.

Python is a nicer environment for playing with common cryptographic primitives such as RSA. Install pycrypto in addition to the core Python distribution.

~% python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2