$manlookup

openssl-asn1parse

(1ssl)

ASN.1 parsing command

User commands15 optionsopenssl 3.5.6-1~deb13u2
openssl asn1parse [-help] [-inform DER|PEM|B64] [-in filename] [-out filename] [-noout] [-offset number] [-length number] [-i] [-oid filename] [-dump] [-dlimit num] [-strparse offset] [-genstr string] [-genconf file] [-strictpem] [-item name]

Options

15
-help

Print out a usage message.

-inform

The input format; the default is PEM. See openssl-format-options(1) for details.

-infilename

The input file, default is standard input.

-outfilename

Output file to place the DER encoded data into. If this option is not present then no data will be output. This is most useful when combined with the -strparse option.

-noout

Don't output the parsed version of the input file.

-offsetnumber

Starting offset to begin parsing, default is start of file.

-lengthnumber

Number of bytes to parse, default is until end of file.

-i

Indents the output according to the "depth" of the structures.

-oidfilename

A file containing additional OBJECT IDENTIFIERs (OIDs). The format of this file is described in the NOTES section below.

-dump

Dump unknown data in hex format.

-dlimitnum

Like -dump, but only the first num bytes are output.

-strparseoffset

Parse the contents octets of the ASN.1 object starting at offset. This option can be used multiple times to "drill down" into a nested structure.

-genstr-genconfstring

Generate encoded data based on string, file or both using ASN1_generate_nconf(3) format. If file only is present then the string is obtained from the default section using the name asn1. The encoded data is passed through the ASN1 parser and printed out as though it came from a file, the contents can thus be examined and written to a file using the -out option.

-strictpem

If this option is used then -inform will be ignored. Without this option any data in a PEM format input file will be treated as being base64 encoded and processed whether it has the normal PEM BEGIN and END markers or not. This option will ignore any data prior to the start of the BEGIN marker, or after an END marker in a PEM file.

-itemname

Attempt to decode and print the data as an ASN1_ITEM name. This can be used to print out the fields of any supported ASN.1 structure if the type is known.

DESCRIPTION

This command is a diagnostic utility that can parse ASN.1 structures. It can also be used to extract data from ASN.1 formatted data.

NOTES

If an OID is not part of OpenSSL's internal table it will be represented in numerical form (for example 1.2.3.4). The file passed to the -oid option allows additional OIDs to be included. Each line consists of three columns, the first column is the OID in numerical format and should be followed by white space. The second column is the "short name" which is a single word followed by whitespace. The final column is the rest of the line and is the "long name". Example:

"1.2.3.4 shortName A long name"

For any OID with an associated short and long name, this command will display the long name.

EXAMPLES

Parse a file:

 openssl asn1parse -in file.pem

Parse a DER file:

 openssl asn1parse -inform DER -in file.der

Generate a simple UTF8String:

 openssl asn1parse -genstr 'UTF8:Hello World'

Generate and write out a UTF8String, don't print parsed output:

 openssl asn1parse -genstr 'UTF8:Hello World' -noout -out utf8.der

Generate using a config file:

 openssl asn1parse -genconf asn1.cnf -noout -out asn1.der

Example config file:

 asn1=SEQUENCE:seq_sect
 [seq_sect]
 field1=BOOL:TRUE
 field2=EXP:0, UTF8:some random string

BUGS

There should be options to change the format of output lines. The output of some ASN.1 types is not well handled (if at all).

See also

openssl(1ssl)ASN1_generate_nconf(3)