OpenSSL "ans1parse -in" - Parse DER File

Q

How to parse a DER file using the OpenSSL "ans1parse" command?

✍: FYIcenter.com

A

You can parse a DER file with OpenSSL "ans1parse -inform DER -in" command as shown in the test below, assuming we have some DER file created from the previous tutorial:

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

OpenSSL> asn1parse -inform DER -in integer.der
    0:d=0  hl=2 l=   2 prim: INTEGER           :FF

OpenSSL> asn1parse -inform DER -in ascii.der
    0:d=0  hl=2 l=  12 prim: IA5STRING         :Hello World!
    
OpenSSL> asn1parse -inform DER -in utf8.der
    0:d=0  hl=2 l=  12 prim: UTF8STRING        :Hello World!
    
OpenSSL> asn1parse -in time.der -inform DER
    0:d=0  hl=2 l=  15 prim: GENERALIZEDTIME   :20161231235959Z

OpenSSL> asn1parse -inform DER -in numeric.der
    0:d=0  hl=2 l=   7 prim: NUMERICSTRING     :3.14159

To read the output of the OpenSSL "ans1parse" command, we need to understand the meaning of each output column:

  • "0:..." - The offset in decimal format of the field in the DER file.
  • "...d=0..." - The depth of the field in a nested structure. "d=0" in the test indicates that the field is the top level field.
  • "...hl=2..." - The header length of the field in bytes. The header includes both field type and field length. "hl=2" in the test indicates that 2 bytes are used to store the field type and field length.
  • "...l= xx..." - The value length of the field in bytes. "l= 2" in the test indicates that 2 types are used to store the integer value of 255.
  • "...prim:..." - The "Primitive" field indicator.
  • "...INTEGER..." - The field type.
  • "...:FF" - The field value. "FF" in the test represents the integer value of 255.

 

OpenSSL "ans1parse -genconf" - Configuration File

OpenSSL "ans1parse -genstr" - Single Primitive Field DER File

OpenSSL "ans1parse" Command

⇑⇑ OpenSSL Tutorials

2016-10-15, 6597🔥, 0💬