openssl-asn1parse
(1ssl)ASN.1 parsing command
Options
15-helpPrint out a usage message.
-informThe input format; the default is PEM. See openssl-format-options(1) for details.
-infilenameThe input file, default is standard input.
-outfilenameOutput 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.
-nooutDon't output the parsed version of the input file.
-offsetnumberStarting offset to begin parsing, default is start of file.
-lengthnumberNumber of bytes to parse, default is until end of file.
-iIndents the output according to the "depth" of the structures.
-oidfilenameA file containing additional OBJECT IDENTIFIERs (OIDs). The format of this file is described in the NOTES section below.
-dumpDump unknown data in hex format.
-dlimitnumLike -dump, but only the first num bytes are output.
-strparseoffsetParse 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-genconfstringGenerate 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.
-strictpemIf 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.
-itemnameAttempt 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
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
COPYRIGHT
Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.