The public key consists of two components: the modulus n
and the public exponent e
. This tutorial demonstrates how to decode public key using OpenSSL.
Let's say we have the following public key:
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAN/ovAmhoNOnE2VoJeUunpEB+CwTyPbK
I8VnQ+rLa75riBtmfYrGdUD8Cv/p+ioL86xwSvX+HYXnkPffEXc7IlUCAwEAAQ==
-----END PUBLIC KEY-----
The openssl rsa
command can be used to decode the public key.
openssl rsa -in test.pub -pubin -text -noout
The meaning of options:
-in test.pub
- specifies the filename to read a public key.-pubin
- reads public key instead of a private key.-text
- specifies that public key components should be printed in text form.-noout
- specifies that an encoded version of the public key should not be included in output.
Output:
RSA Public-Key: (512 bit)
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
Exponent: 65537 (0x10001)
Leave a Comment
Cancel reply