1ASN1PARSE(1)                        OpenSSL                       ASN1PARSE(1)
2
3
4

NAME

6       openssl-asn1parse, asn1parse - ASN.1 parsing tool
7

SYNOPSIS

9       openssl asn1parse [-help] [-inform PEM|DER] [-in filename] [-out
10       filename] [-noout] [-offset number] [-length number] [-i] [-oid
11       filename] [-dump] [-dlimit num] [-strparse offset] [-genstr string]
12       [-genconf file] [-strictpem] [-item name]
13

DESCRIPTION

15       The asn1parse command is a diagnostic utility that can parse ASN.1
16       structures. It can also be used to extract data from ASN.1 formatted
17       data.
18

OPTIONS

20       -help
21           Print out a usage message.
22
23       -inform DER|PEM
24           The input format. DER is binary format and PEM (the default) is
25           base64 encoded.
26
27       -in filename
28           The input file, default is standard input.
29
30       -out filename
31           Output file to place the DER encoded data into. If this option is
32           not present then no data will be output. This is most useful when
33           combined with the -strparse option.
34
35       -noout
36           Don't output the parsed version of the input file.
37
38       -offset number
39           Starting offset to begin parsing, default is start of file.
40
41       -length number
42           Number of bytes to parse, default is until end of file.
43
44       -i  Indents the output according to the "depth" of the structures.
45
46       -oid filename
47           A file containing additional OBJECT IDENTIFIERs (OIDs). The format
48           of this file is described in the NOTES section below.
49
50       -dump
51           Dump unknown data in hex format.
52
53       -dlimit num
54           Like -dump, but only the first num bytes are output.
55
56       -strparse offset
57           Parse the contents octets of the ASN.1 object starting at offset.
58           This option can be used multiple times to "drill down" into a
59           nested structure.
60
61       -genstr string, -genconf file
62           Generate encoded data based on string, file or both using
63           ASN1_generate_nconf(3) format. If file only is present then the
64           string is obtained from the default section using the name asn1.
65           The encoded data is passed through the ASN1 parser and printed out
66           as though it came from a file, the contents can thus be examined
67           and written to a file using the out option.
68
69       -strictpem
70           If this option is used then -inform will be ignored. Without this
71           option any data in a PEM format input file will be treated as being
72           base64 encoded and processed whether it has the normal PEM BEGIN
73           and END markers or not. This option will ignore any data prior to
74           the start of the BEGIN marker, or after an END marker in a PEM
75           file.
76
77       -item name
78           Attempt to decode and print the data as ASN1_ITEM name. This can be
79           used to print out the fields of any supported ASN.1 structure if
80           the type is known.
81
82   Output
83       The output will typically contain lines like this:
84
85         0:d=0  hl=4 l= 681 cons: SEQUENCE
86
87       .....
88
89         229:d=3  hl=3 l= 141 prim: BIT STRING
90         373:d=2  hl=3 l= 162 cons: cont [ 3 ]
91         376:d=3  hl=3 l= 159 cons: SEQUENCE
92         379:d=4  hl=2 l=  29 cons: SEQUENCE
93         381:d=5  hl=2 l=   3 prim: OBJECT            :X509v3 Subject Key Identifier
94         386:d=5  hl=2 l=  22 prim: OCTET STRING
95         410:d=4  hl=2 l= 112 cons: SEQUENCE
96         412:d=5  hl=2 l=   3 prim: OBJECT            :X509v3 Authority Key Identifier
97         417:d=5  hl=2 l= 105 prim: OCTET STRING
98         524:d=4  hl=2 l=  12 cons: SEQUENCE
99
100       .....
101
102       This example is part of a self-signed certificate. Each line starts
103       with the offset in decimal. d=XX specifies the current depth. The depth
104       is increased within the scope of any SET or SEQUENCE. hl=XX gives the
105       header length (tag and length octets) of the current type. l=XX gives
106       the length of the contents octets.
107
108       The -i option can be used to make the output more readable.
109
110       Some knowledge of the ASN.1 structure is needed to interpret the
111       output.
112
113       In this example the BIT STRING at offset 229 is the certificate public
114       key.  The contents octets of this will contain the public key
115       information. This can be examined using the option -strparse 229 to
116       yield:
117
118           0:d=0  hl=3 l= 137 cons: SEQUENCE
119           3:d=1  hl=3 l= 129 prim: INTEGER           :E5D21E1F5C8D208EA7A2166C7FAF9F6BDF2059669C60876DDB70840F1A5AAFA59699FE471F379F1DD6A487E7D5409AB6A88D4A9746E24B91D8CF55DB3521015460C8EDE44EE8A4189F7A7BE77D6CD3A9AF2696F486855CF58BF0EDF2B4068058C7A947F52548DDF7E15E96B385F86422BEA9064A3EE9E1158A56E4A6F47E5897
120         135:d=1  hl=2 l=   3 prim: INTEGER           :010001
121

NOTES

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

EXAMPLES

135       Parse a file:
136
137        openssl asn1parse -in file.pem
138
139       Parse a DER file:
140
141        openssl asn1parse -inform DER -in file.der
142
143       Generate a simple UTF8String:
144
145        openssl asn1parse -genstr 'UTF8:Hello World'
146
147       Generate and write out a UTF8String, don't print parsed output:
148
149        openssl asn1parse -genstr 'UTF8:Hello World' -noout -out utf8.der
150
151       Generate using a config file:
152
153        openssl asn1parse -genconf asn1.cnf -noout -out asn1.der
154
155       Example config file:
156
157        asn1=SEQUENCE:seq_sect
158
159        [seq_sect]
160
161        field1=BOOL:TRUE
162        field2=EXP:0, UTF8:some random string
163

BUGS

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

SEE ALSO

169       ASN1_generate_nconf(3)
170
172       Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
173
174       Licensed under the OpenSSL license (the "License").  You may not use
175       this file except in compliance with the License.  You can obtain a copy
176       in the file LICENSE in the source distribution or at
177       <https://www.openssl.org/source/license.html>.
178
179
180
1811.1.1g                            2020-04-23                      ASN1PARSE(1)
Impressum