1OPENSSL-ASN1PARSE(1ossl)            OpenSSL           OPENSSL-ASN1PARSE(1ossl)
2
3
4

NAME

6       openssl-asn1parse - ASN.1 parsing command
7

SYNOPSIS

9       openssl asn1parse [-help] [-inform DER|PEM] [-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       This command is a diagnostic utility that can parse ASN.1 structures.
16       It can also be used to extract data from ASN.1 formatted data.
17

OPTIONS

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

NOTES

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

EXAMPLES

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

BUGS

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

SEE ALSO

170       openssl(1), ASN1_generate_nconf(3)
171
173       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
174
175       Licensed under the Apache License 2.0 (the "License").  You may not use
176       this file except in compliance with the License.  You can obtain a copy
177       in the file LICENSE in the source distribution or at
178       <https://www.openssl.org/source/license.html>.
179
180
181
1823.0.5                             2022-07-05          OPENSSL-ASN1PARSE(1ossl)
Impressum