OpenSSL "rsa -text" - Print RSA Key in Text

Q

How to print RSA private key contents in text format using OpenSSL "rsa" command?

✍: FYIcenter.com

A

If you want to see contents of an RSA private key in text format, you can use the OpenSSL "rsa -text" command as shown below:

C:\Users\fyicenter>\local\openssl\openssl.exe

OpenSSL> rsa -in my_rsa.key -text -noout
Private-Key: (2048 bit)
modulus:
    00:c7:54:90:53:51:9f:b0:13:41:e9:75:36:9e:aa:
    f0:20:79:b5:22:65:cf:01:cb:08:9d:03:5f:84:57:
    29:ce:99:2e:dc:a9:a6:d0:ba:43:64:5d:68:aa:4a:
    8b:34:b9:61:d2:a5:48:22:57:ee:30:d9:d5:34:b0:
    28:cd:b5:1b:68:96:a5:15:47:52:18:f0:15:97:b8:
    c5:45:9c:69:0d:a8:be:77:85:36:c1:ed:78:30:ed:
    e4:4f:0c:bb:1f:76:5e:44:ac:d6:92:52:f6:14:27:
    8a:a3:67:36:d2:0c:c5:39:fc:5d:78:fc:12:c7:d9:
    41:4f:b7:9f:14:d7:39:34:74:4f:74:f6:cf:fd:ed:
    59:c7:55:6a:07:cc:00:29:38:11:c1:a7:d0:98:57:
    d8:51:b6:e4:d8:27:39:7e:d6:7c:ca:15:9c:e3:7f:
    b6:a9:6c:e1:5a:6e:88:83:c9:27:6d:aa:4f:2c:c3:
    f0:e9:b1:73:c0:3f:9c:93:ee:9d:ef:36:c2:1b:ef:
    8d:ac:1b:97:1f:ce:7c:88:32:5f:cc:b8:2b:c2:27:
    3b:7d:6d:1c:46:21:7e:c8:1a:62:4e:60:30:e8:6f:
    47:1f:40:90:bb:c1:cd:06:03:1f:5d:92:2e:62:36:
    44:47:83:0e:6e:6a:92:1a:24:53:c8:df:66:10:5b:
    52:5b
publicExponent: 65537 (0x10001)
privateExponent:
    00:9c:03:6d:1f:39:90:d2:40:90:63:48:d1:e2:68:
    8a:9f:f0:82:bc:94:90:ec:a7:5c:6b:80:7b:5f:5a:
    d5:a7:15:b0:5f:18:0e:2f:ea:c9:da:a1:5d:cd:83:
    a0:e7:38:7d:ff:60:4c:50:4d:20:6a:6d:e4:f9:63:
    33:dc:a5:f6:f8:ea:87:f5:5a:a8:40:4a:91:ab:f9:
    fb:b5:9b:51:82:56:64:15:aa:57:8c:7b:f0:89:e3:
    78:c2:02:85:e7:7f:3f:13:63:70:62:80:ba:88:55:
    d6:a6:44:9f:dc:d2:10:00:6d:ad:3f:87:94:af:85:
    35:20:4e:e9:1d:67:c3:27:70:cc:1d:f5:75:dc:ca:
    42:5d:b0:cd:09:7b:d4:a4:ec:fd:95:a8:9f:4b:d3:
    00:34:c3:12:64:fb:35:20:08:b4:40:ea:b6:ce:6a:
    eb:6a:be:a8:38:34:7e:82:df:b9:ef:5b:a6:32:94:
    b6:ee:12:52:ab:9e:6a:7e:d7:c6:84:53:ec:30:04:
    f8:7b:91:7f:dd:c0:f7:b9:f0:0d:bc:b5:9d:85:1d:
    e1:c2:cb:40:85:a0:0d:b2:9d:de:12:f5:e4:c9:1c:
    bf:7a:26:71:03:a0:e8:77:11:77:fc:2f:36:be:93:
    ab:03:0e:5d:4f:47:36:4b:1a:bb:e9:dc:87:8e:cc:
    ce:61
prime1:
    00:e6:3d:cd:6d:77:84:8e:c0:20:d8:68:2d:80:e2:
    4d:42:88:c0:40:c1:74:0a:e1:1c:53:e0:85:5c:b2:
    3a:7e:11:34:2f:63:3b:32:ca:06:c3:f8:d8:96:8e:
    61:f3:1f:26:8f:1c:5a:cc:04:32:a0:86:d0:ff:00:
    a6:74:61:92:d0:ad:bd:50:ac:fe:a5:e8:9c:2e:fe:
    4c:c7:9f:4e:d3:3e:bc:a9:e7:09:f5:89:28:ed:8c:
    bc:8a:4f:b9:b6:53:d8:55:5c:a4:a5:61:35:e5:32:
    5d:44:4b:87:55:0e:f1:3c:cd:05:35:c7:52:64:b2:
    0d:e0:bf:2b:76:f9:f6:9d:2b
prime2:
    00:dd:a1:74:e0:2c:f6:f6:a8:4e:3b:8a:b4:1f:14:
    eb:fc:17:3d:af:f2:96:44:26:99:85:be:2d:06:14:
    d9:e6:11:e0:28:0f:29:f3:43:3c:ff:09:c6:6b:ef:
    79:13:bd:e0:06:b8:cb:31:d4:1b:3d:bc:ac:53:51:
    1a:73:49:34:86:f9:28:59:5f:06:72:62:7a:1e:03:
    27:28:cf:6a:05:fa:52:da:72:e9:be:b8:c6:9f:94:
    f8:f5:1c:8f:5a:5e:c3:07:95:d0:05:98:3b:81:18:
    f4:61:39:29:ee:7d:f6:9f:2b:1c:ab:76:9d:e5:7a:
    7d:08:af:ef:ec:ef:50:67:91
exponent1:
    7e:b7:42:e9:5d:5f:0a:45:b9:8e:01:00:12:2f:fa:
    7f:84:cd:f2:95:c5:ec:fa:e9:e1:4b:ef:7a:0d:e9:
    5d:5a:d0:92:c8:15:5b:a5:8e:c5:aa:9e:61:76:29:
    78:6a:0b:89:b5:fc:4e:ce:7c:a2:96:b0:4d:b8:28:
    e4:62:93:2f:e0:7f:11:f8:b4:09:d1:94:ab:d4:6f:
    a3:6a:0d:32:fc:13:4f:9b:05:83:2a:22:e9:62:8c:
    9d:be:b5:22:20:d1:2e:61:d7:87:e1:91:8c:fc:04:
    12:c3:52:cf:40:73:0a:98:77:a6:9a:75:c1:4f:b1:
    8d:a1:09:25:e8:fa:8e:93
exponent2:
    19:76:f5:a0:d4:49:c3:e9:6e:a3:b4:ba:21:60:1c:
    05:28:fe:73:7a:e1:fd:0e:9a:51:1d:9a:ba:ba:26:
    97:22:b2:a8:a7:a5:60:47:f7:78:2e:3d:58:25:79:
    b9:e4:f5:1a:90:9c:f8:2a:b0:be:95:31:0f:99:9f:
    fa:63:0c:df:fd:3c:bf:98:05:7b:9b:09:00:ed:c7:
    d0:0e:94:d5:fe:ff:0a:0e:6e:00:f5:e6:0c:6b:e7:
    76:f2:43:1e:55:08:ff:94:1d:04:a7:8b:1e:b8:29:
    4c:0a:6f:60:f1:a4:26:81:a3:97:a7:d7:58:88:8c:
    59:35:2d:d2:01:65:31:a1
coefficient:
    4a:72:e8:f6:9a:47:4d:ee:ee:70:92:3f:8f:e9:37:
    68:c6:83:c5:0d:dd:d1:7d:1c:68:ae:19:c6:2e:29:
    44:91:a8:50:aa:34:f7:d8:a7:9d:53:78:22:6d:b3:
    8e:b3:f1:ee:96:f4:f2:67:a6:8f:9c:15:f5:95:65:
    59:8c:5c:18:e6:de:5b:8f:30:71:79:c2:83:34:0d:
    c6:42:86:90:bb:15:eb:a9:db:f6:1c:33:8d:25:b9:
    fa:84:c2:39:bb:6a:dd:35:f0:20:97:34:41:cb:07:
    4a:89:82:03:bd:a4:8e:ed:f7:43:51:53:73:48:9d:
    8b:42:c6:7d:0f:08:d1:4a

This test tells us that an RSA key (private key and public key pair) is made of:

modulus, also called n: The modulus part of the private key and the public key
publicExponent, also called e: The exponent part of the public key
privateExponent, also called d: The exponent part of the private key
prime1, also called p: The first prime number
prime2, also called q: The second prime number
coefficient, also called qInv (Inverse of q): qInv * q  mod p = 1
exponent1, also called dp: d mod (p-1)
exponent2, also called dq: d mod (q-1)

Options used in this command are:

  • "-in my_rsa.key" - Read the RSA key file from: C:\Users\fyicenter\my_rsa.key
  • "-text" - Print out key information in text format.
  • "-noout" - Do not include the key itself in the output.

 

OpenSSL "rsa -pubout" - Extract RSA Public Key

OpenSSL "rsa" Command Options

OpenSSL "genrsa" and "rsa" Commands

⇑⇑ OpenSSL Tutorials

2017-02-03, 932👍, 0💬