OpenSSL "rsa -pubin" - View RSA Public Key

Q

How to view contents of an RSA public key file using OpenSSL "rsa" command?

✍: FYIcenter.com

A

If you want to view contents of an RSA public key stored in a file, you can use the OpenSSL "rsa -pubin" command as shown below:

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

OpenSSL> rsa -in my_rsa_pub.key -pubin -text -noout
Public-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
Exponent: 65537 (0x10001)

Options used in this command are:

  • "-in my_rsa_pub.key" - Read the RSA public key file from: C:\Users\fyicenter\my_rsa_pub.key.
  • "-pubin" - Read the input as a public key, instead of private key (together with public key).
  • "-text" - Print out key information in text format.
  • "-noout" - Do not include the key itself in the output.

The output shows that an RSA public key contains 2 components:

modulus, also called n - The modulus part of the public key
exponent, also called e - The exponent part of the public key

 

OpenSSL "genrsa 32" - Generate RSA Short Keys

OpenSSL "rsa -pubout" - Extract RSA Public Key

OpenSSL "genrsa" and "rsa" Commands

⇑⇑ OpenSSL Tutorials

2017-01-29, 15000👍, 0💬