summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/d2i_ASN1_OCTET_STRING.3
blob: c985bc8b68f85be323b4b17abaa77e2aaf86ca80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
.\"	$OpenBSD: d2i_ASN1_OCTET_STRING.3,v 1.12 2018/03/27 17:35:50 schwarze Exp $
.\"
.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 27 2018 $
.Dt D2I_ASN1_OCTET_STRING 3
.Os
.Sh NAME
.Nm d2i_ASN1_OCTET_STRING ,
.Nm i2d_ASN1_OCTET_STRING ,
.Nm d2i_ASN1_BIT_STRING ,
.Nm i2d_ASN1_BIT_STRING ,
.Nm d2i_ASN1_INTEGER ,
.Nm i2d_ASN1_INTEGER ,
.Nm d2i_ASN1_UINTEGER ,
.Nm d2i_ASN1_ENUMERATED ,
.Nm i2d_ASN1_ENUMERATED ,
.Nm d2i_ASN1_UTF8STRING ,
.Nm i2d_ASN1_UTF8STRING ,
.Nm d2i_ASN1_IA5STRING ,
.Nm i2d_ASN1_IA5STRING ,
.Nm d2i_ASN1_UNIVERSALSTRING ,
.Nm i2d_ASN1_UNIVERSALSTRING ,
.Nm d2i_ASN1_BMPSTRING ,
.Nm i2d_ASN1_BMPSTRING ,
.Nm d2i_ASN1_GENERALSTRING ,
.Nm i2d_ASN1_GENERALSTRING ,
.Nm d2i_ASN1_T61STRING ,
.Nm i2d_ASN1_T61STRING ,
.Nm d2i_ASN1_VISIBLESTRING ,
.Nm i2d_ASN1_VISIBLESTRING ,
.Nm d2i_ASN1_PRINTABLESTRING ,
.Nm i2d_ASN1_PRINTABLESTRING ,
.Nm d2i_ASN1_PRINTABLE ,
.Nm i2d_ASN1_PRINTABLE ,
.Nm d2i_DIRECTORYSTRING ,
.Nm i2d_DIRECTORYSTRING ,
.Nm d2i_DISPLAYTEXT ,
.Nm i2d_DISPLAYTEXT ,
.Nm d2i_ASN1_GENERALIZEDTIME ,
.Nm i2d_ASN1_GENERALIZEDTIME ,
.Nm d2i_ASN1_UTCTIME ,
.Nm i2d_ASN1_UTCTIME ,
.Nm d2i_ASN1_TIME ,
.Nm i2d_ASN1_TIME
.Nd decode and encode ASN1_STRING objects
.Sh SYNOPSIS
.In openssl/asn1.h
.Ft ASN1_OCTET_STRING *
.Fo d2i_ASN1_OCTET_STRING
.Fa "ASN1_OCTET_STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_OCTET_STRING
.Fa "ASN1_OCTET_STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_BIT_STRING *
.Fo d2i_ASN1_BIT_STRING
.Fa "ASN1_BIT_STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_BIT_STRING
.Fa "ASN1_BIT_STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_INTEGER *
.Fo d2i_ASN1_INTEGER
.Fa "ASN1_INTEGER **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_INTEGER
.Fa "ASN1_INTEGER *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_INTEGER *
.Fo d2i_ASN1_UINTEGER
.Fa "ASN1_INTEGER **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft ASN1_ENUMERATED *
.Fo d2i_ASN1_ENUMERATED
.Fa "ASN1_ENUMERATED **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_ENUMERATED
.Fa "ASN1_ENUMERATED *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_UTF8STRING *
.Fo d2i_ASN1_UTF8STRING
.Fa "ASN1_UTF8STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_UTF8STRING
.Fa "ASN1_UTF8STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_IA5STRING *
.Fo d2i_ASN1_IA5STRING
.Fa "ASN1_IA5STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_IA5STRING
.Fa "ASN1_IA5STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_UNIVERSALSTRING *
.Fo d2i_ASN1_UNIVERSALSTRING
.Fa "ASN1_UNIVERSALSTRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_UNIVERSALSTRING
.Fa "ASN1_UNIVERSALSTRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_BMPSTRING *
.Fo d2i_ASN1_BMPSTRING
.Fa "ASN1_BMPSTRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_BMPSTRING
.Fa "ASN1_BMPSTRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_GENERALSTRING *
.Fo d2i_ASN1_GENERALSTRING
.Fa "ASN1_GENERALSTRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_GENERALSTRING
.Fa "ASN1_GENERALSTRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_T61STRING *
.Fo d2i_ASN1_T61STRING
.Fa "ASN1_T61STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_T61STRING
.Fa "ASN1_T61STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_VISIBLESTRING *
.Fo d2i_ASN1_VISIBLESTRING
.Fa "ASN1_VISIBLESTRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_VISIBLESTRING
.Fa "ASN1_VISIBLESTRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_PRINTABLESTRING *
.Fo d2i_ASN1_PRINTABLESTRING
.Fa "ASN1_PRINTABLESTRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_PRINTABLESTRING
.Fa "ASN1_PRINTABLESTRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_STRING *
.Fo d2i_ASN1_PRINTABLE
.Fa "ASN1_STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_PRINTABLE
.Fa "ASN1_STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_STRING *
.Fo d2i_DIRECTORYSTRING
.Fa "ASN1_STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_DIRECTORYSTRING
.Fa "ASN1_STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_STRING *
.Fo d2i_DISPLAYTEXT
.Fa "ASN1_STRING **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_DISPLAYTEXT
.Fa "ASN1_STRING *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_GENERALIZEDTIME *
.Fo d2i_ASN1_GENERALIZEDTIME
.Fa "ASN1_GENERALIZEDTIME **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_GENERALIZEDTIME
.Fa "ASN1_GENERALIZEDTIME *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_UTCTIME *
.Fo d2i_ASN1_UTCTIME
.Fa "ASN1_UTCTIME **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_UTCTIME
.Fa "ASN1_UTCTIME *val_in"
.Fa "unsigned char **der_out"
.Fc
.Ft ASN1_TIME *
.Fo d2i_ASN1_TIME
.Fa "ASN1_TIME **val_out"
.Fa "const unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_TIME
.Fa "ASN1_TIME *val_in"
.Fa "unsigned char **der_out"
.Fc
.Sh DESCRIPTION
These functions decode and encode various ASN.1 built-in types
that can be represented by
.Vt ASN1_STRING
objects.
For details about the semantics, examples, caveats, and bugs, see
.Xr ASN1_item_d2i 3 .
.Pp
The format consists of one identifier octet,
one or more length octets,
and one or more content octets.
The identifier octets and corresponding ASN.1 types are as follows:
.Bl -column ASN1_GENERALIZEDTIME identifier
.It Em OpenSSL type Ta Em identifier Ta Em ASN.1 type
.It Ta
.It Vt ASN1_OCTET_STRING    Ta 0x04 Ta OCTET STRING
.It Vt ASN1_BIT_STRING      Ta 0x03 Ta BIT STRING
.It Vt ASN1_INTEGER         Ta 0x02 Ta INTEGER
.It Vt ASN1_ENUMERATED      Ta 0x0a Ta ENUMERATED
.It Vt ASN1_UTF8STRING      Ta 0x0c Ta UTF8String
.It Vt ASN1_IA5STRING       Ta 0x16 Ta IA5String
.It Vt ASN1_UNIVERSALSTRING Ta 0x1c Ta UniversalString
.It Vt ASN1_BMPSTRING       Ta 0x1e Ta BMPString
.It Vt ASN1_GENERALSTRING   Ta 0x1b Ta GeneralString
.It Vt ASN1_T61STRING       Ta 0x14 Ta T61String
.It Vt ASN1_VISIBLESTRING   Ta 0x1a Ta VisibleString
.It Vt ASN1_PRINTABLESTRING Ta 0x13 Ta PrintableString
.It Vt ASN1_GENERALIZEDTIME Ta 0x18 Ta GeneralizedTime
.It Vt ASN1_UTCTIME         Ta 0x17 Ta UTCTime
.El
.Pp
.Fn d2i_DIRECTORYSTRING
and
.Fn i2d_DIRECTORYSTRING
decode and encode an ASN.1
.Vt DirectoryString
structure defined in RFC 5280 section 4.1.2.4
and used for ASN.1
.Vt EDIPartyName
structures; see
.Xr EDIPARTYNAME_new 3 .
When decoding, it accepts any of the types UTF8String, UniversalString,
BMPString, T61String, or PrintableString.
When encoding,
it writes out the character string type that is actually passed in.
.Pp
.Fn d2i_ASN1_PRINTABLE
and
.Fn i2d_ASN1_PRINTABLE
are non-standard variants of
.Fn d2i_DIRECTORYSTRING
and
.Fn i2d_DIRECTORYSTRING
that also accept IA5String, NumericString, BIT STRING, and SEQUENCE
ASN.1 values as well as ASN.1 values with unknown identifier
octets (0x07, 0x08, 0x09, 0x0b, 0x0d, 0x0e, 0x0f, 0x1d, and 0x1f).
Even though the standard requires the use of
.Vt DirectoryString
in the relative distinguished names described in
.Xr X509_NAME_ENTRY_new 3 ,
the library accepts this wider range of choices.
.Pp
.Fn d2i_DISPLAYTEXT
and
.Fn i2d_DISPLAYTEXT
decode and encode an ASN.1
.Vt DisplayText
structure defined in RFC 5280 section 4.2.1.4
and used for ASN.1
.Vt UserNotice
structures in certificate policies; see
.Xr USERNOTICE_new 3 .
When decoding, it accepts any of the types UTF8String, IA5String,
BMPString, or VisibleString.
When encoding,
it writes out the character string type that is actually passed in.
.Pp
.Fn d2i_ASN1_TIME
and
.Fn i2d_ASN1_TIME
decode and encode an ASN.1
.Vt Time
structure defined in RFC 5280 section 4.1
and used for ASN.1
.Vt Validity
structures in certificates; see
.Xr X509_VAL_new 3 .
They are also used for certificate revocation lists; see
.Xr X509_CRL_INFO_new 3 .
When decoding, it accepts either GeneralizedTime or UTCTime.
When encoding, it writes out the time type that is actually passed in.
.Pp
.Fn d2i_ASN1_UINTEGER
is similar to
.Fn d2i_ASN1_INTEGER
except that it ignores the sign bit in the BER encoding and treats
all integers as positive.
It helps to process BER input produced by broken software
that neglects adding a leading NUL content byte where required.
.Sh RETURN VALUES
The
.Fn d2i_*
decoding functions return an
.Vt ASN1_STRING
object or
.Dv NULL
if an error occurs.
.Pp
The
.Fn i2d_*
encoding functions return the number of bytes successfully encoded
or a negative value if an error occurs.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr ASN1_STRING_new 3
.Sh STANDARDS
ITU-T Recommendation X.680, also known as ISO/IEC 8824-1:
Information technology - Abstract Syntax Notation One (ASN.1):
Specification of basic notation
.Pp
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
Certificate Revocation List (CRL) Profile
.Sh HISTORY
.Fn d2i_ASN1_OCTET_STRING ,
.Fn i2d_ASN1_OCTET_STRING ,
.Fn d2i_ASN1_BIT_STRING ,
.Fn i2d_ASN1_BIT_STRING ,
.Fn d2i_ASN1_INTEGER ,
.Fn i2d_ASN1_INTEGER ,
.Fn d2i_ASN1_IA5STRING ,
.Fn i2d_ASN1_IA5STRING ,
.Fn d2i_ASN1_T61STRING ,
.Fn i2d_ASN1_T61STRING ,
.Fn d2i_ASN1_PRINTABLESTRING ,
.Fn i2d_ASN1_PRINTABLESTRING
.Fn d2i_ASN1_PRINTABLE ,
.Fn i2d_ASN1_PRINTABLE ,
.Fn d2i_ASN1_UTCTIME ,
and
.Fn i2d_ASN1_UTCTIME
first appeared in SSLeay 0.5.1 and have been available since
.Ox 2.4 .
.Pp
.Fn d2i_ASN1_BMPSTRING
and
.Fn i2d_ASN1_BMPSTRING
first appeared in SSLeay 0.9.1.
.Fn d2i_ASN1_ENUMERATED ,
.Fn i2d_ASN1_ENUMERATED ,
.Fn d2i_ASN1_GENERALIZEDTIME ,
.Fn i2d_ASN1_GENERALIZEDTIME ,
.Fn d2i_ASN1_TIME ,
and
.Fn i2d_ASN1_TIME
first appeared in OpenSSL 0.9.2b.
.Fn d2i_ASN1_UINTEGER ,
.Fn d2i_ASN1_UTF8STRING ,
.Fn i2d_ASN1_UTF8STRING ,
.Fn d2i_ASN1_VISIBLESTRING ,
.Fn i2d_ASN1_VISIBLESTRING ,
.Fn d2i_DIRECTORYSTRING ,
.Fn i2d_DIRECTORYSTRING ,
.Fn d2i_DISPLAYTEXT
and
.Fn i2d_DISPLAYTEXT
first appeared in OpenSSL 0.9.3.
These functions have been available since
.Ox 2.6 .
.Pp
.Fn d2i_ASN1_UNIVERSALSTRING ,
.Fn i2d_ASN1_UNIVERSALSTRING ,
.Fn d2i_ASN1_GENERALSTRING ,
and
.Fn i2d_ASN1_GENERALSTRING
first appeared in OpenSSL 0.9.7 and have been available since
.Ox 3.2 .