OpenSSL "dsa -pubin" - View DSA Public Key

Q

How to view contents of a DSA public key file using OpenSSL "dsa" command?

✍: FYIcenter.com

A

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

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

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

Options used in this command are:

  • "-in my_dsa_2048_pub.key" - Read the DSA public key file.
  • "-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 a DSA public key contains 4 components:

pub, also called Y: The public key, Y = (G**X mod P), X is the private key
P: The first prime number of 2048 bits.
Q: The second prime number, where (P-1) is multiple of Q.
G: An integer between 1 and P, and generated by (h**((p–1)/q) mod p), 
   where is h is any number.

 

OpenSSL "dsaparam 512" - Generate DSA Short Keys

OpenSSL "dsa -pubout" - Extract DSA Public Key

OpenSSL "gendsa" and "dsa" Commands

⇑⇑ OpenSSL Tutorials

2016-12-28, 702👍, 0💬