OpenSSL "ans1parse" - DSA Public Key in ASN.1 Structure

Q

How to view the ASN.1 structure of an DSA public key using the OpenSSL "asn1parse" command?

✍: FYIcenter.com

A

You can use the OpenSSL "asn1parse" command to view the ASN.1 structure of an DSA public key as shown in the test below:

C:\Users\fyicenter>\local\openssl\openssl 
   pkey -in dsa_pri.key -pubout -out dsa_pub.key

C:\Users\fyicenter>\local\openssl\openssl asn1parse -in dsa_pub.key -i
    0:d=0  hl=3 l= 240 cons: SEQUENCE
    3:d=1  hl=3 l= 168 cons:  SEQUENCE
    6:d=2  hl=2 l=   7 prim:   OBJECT            :dsaEncryption
   15:d=2  hl=3 l= 156 cons:   SEQUENCE
   18:d=3  hl=2 l=  65 prim:    INTEGER           :B2A22FE456DD10930CEED27DE2E58
E69E27CB52E14BE655C5D0F4EDC4A627A800A211DABD9B07D974EF3C997DD198E31C2B238696CBF5
E9984B1EE3D11B2D9E3
   85:d=3  hl=2 l=  21 prim:    INTEGER           :A17145E13E0034692FC1BD85BDF88
E1AA578818D
  108:d=3  hl=2 l=  64 prim:    INTEGER           :79F4E4FB123458BFDD388E0CC90D7
76C3CBB9C82E10668C71318D322AF5968EE8FB9F64F9AC09A9AAA24AD8DED795B7CE4BB81E02047A
AC4D3E95513AA8FD5DD
  174:d=1  hl=2 l=  67 prim:  BIT STRING

C:\Users\fyicenter>\local\openssl\openssl 
   asn1parse -in dsa_pub.key -strparse 174
    0:d=0  hl=2 l=  64 prim: INTEGER           :424A04378703B51FAD65CEC2C59BF6FA
2CD40AA64C43975B564004519798E5B2FCC74D4DE407B73812341ABBCE0878CD2CA23A4501992E63
842531BCAA7A9702  

C:\Users\fyicenter>\local\openssl\openssl 
   pkey -pubin -in dsa_pub.key -text -noout
pub:
    42:4a:04:37:87:03:b5:1f:ad:65:ce:c2:c5:9b:f6:
    fa:2c:d4:0a:a6:4c:43:97:5b:56:40:04:51:97:98:
    e5:b2:fc:c7:4d:4d:e4:07:b7:38:12:34:1a:bb:ce:
    08:78:cd:2c:a2:3a:45:01:99:2e:63:84:25:31:bc:
    aa:7a:97:02
P:
    00:b2:a2:2f:e4:56:dd:10:93:0c:ee:d2:7d:e2:e5:
    8e:69:e2:7c:b5:2e:14:be:65:5c:5d:0f:4e:dc:4a:
    62:7a:80:0a:21:1d:ab:d9:b0:7d:97:4e:f3:c9:97:
    dd:19:8e:31:c2:b2:38:69:6c:bf:5e:99:84:b1:ee:
    3d:11:b2:d9:e3
Q:
    00:a1:71:45:e1:3e:00:34:69:2f:c1:bd:85:bd:f8:
    8e:1a:a5:78:81:8d
G:
    79:f4:e4:fb:12:34:58:bf:dd:38:8e:0c:c9:0d:77:
    6c:3c:bb:9c:82:e1:06:68:c7:13:18:d3:22:af:59:
    68:ee:8f:b9:f6:4f:9a:c0:9a:9a:aa:24:ad:8d:ed:
    79:5b:7c:e4:bb:81:e0:20:47:aa:c4:d3:e9:55:13:
    aa:8f:d5:dd  

Note about the test:

  • The ASN.1 structure of a DSA public key is identical to the DSA private key, except that the public integer is wrapped in an BIT STRING instead of an OCTET STRING.
  • The ASN.1 structure of a DSA public key has no version field.

 

OpenSSL "ans1parse" - Configuration File for DSA Public Key

OpenSSL "ans1parse" - Configuration File for DSA Private Key

OpenSSL "ans1parse" Command

⇑⇑ OpenSSL Tutorials

2016-09-26, 7229🔥, 0💬