Decode Private Key using OpenSSL

Decode Private Key using OpenSSL

Private key consist of various components such as modulus, public exponent, private exponent, coefficient, etc. This tutorial demonstrates how to decode private key using OpenSSL.

Let's say we have the following private key:

-----BEGIN PRIVATE KEY-----
MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA3+i8CaGg06cTZWgl
5S6ekQH4LBPI9sojxWdD6strvmuIG2Z9isZ1QPwK/+n6KgvzrHBK9f4dheeQ998R
dzsiVQIDAQABAkA3eyS0wj7mkvykYPUa371csv86dMCUHixU6qySjkspSGcvdqNQ
UuAfRJ97n8m8wkNSHhF2HIWH2lPdC/MsZX/VAiEA8QLAZXzsUiEIQ04enLZRq0cv
YkD8mLyXVpT56ZrdEDsCIQDt1bMedIH1kCcAvg4PHAugXw1NeJSvpOpUqOyPwmB+
rwIhAJDhq5EW4OWaT+JOAt8IRt4k49o34OFcdcmpsvZ4jy3jAiA7n+2N3wuNspv0
lbEUnKVViT7egzJTbnbIzqivyb1DRQIhAKbr3cYY4mk0HKFQg3oEhWi2stSPulYz
KNkxLcXmqXjr
-----END PRIVATE KEY-----

Private key can be decoded by using openssl rsa command.

openssl rsa -in test.key -text -noout

The meaning of options:

  • -in test.key - specifies the filename to read a private key.
  • -text - specifies that private key components should be printed in text form.
  • -noout - specifies that an encoded version of the private key should not be included in output.

A part of the output:

RSA Private-Key: (512 bit, 2 primes)
modulus:
    00:df:e8:bc:09:a1:a0:d3:a7:13:65:68:25:e5:2e:
    9e:91:01:f8:2c:13:c8:f6:ca:23:c5:67:43:ea:cb:
    6b:be:6b:88:1b:66:7d:8a:c6:75:40:fc:0a:ff:e9:
    fa:2a:0b:f3:ac:70:4a:f5:fe:1d:85:e7:90:f7:df:
    11:77:3b:22:55
publicExponent: 65537 (0x10001)
privateExponent:
    37:7b:24:b4:c2:3e:e6:92:fc:a4:60:f5:1a:df:bd:
    5c:b2:ff:3a:74:c0:94:1e:2c:54:ea:ac:92:8e:4b:
    29:48:67:2f:76:a3:50:52:e0:1f:44:9f:7b:9f:c9:
    bc:c2:43:52:1e:11:76:1c:85:87:da:53:dd:0b:f3:
    2c:65:7f:d5
...

Leave a Comment

Cancel reply

Your email address will not be published.