summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/d2i_ASN1_OBJECT.3
blob: 09a17ced7cf0b02801bc26bc0d9e01a1803076a2 (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
.\"	$OpenBSD: d2i_ASN1_OBJECT.3,v 1.9 2018/04/25 15:17:52 schwarze Exp $
.\"	OpenSSL 05ea606a May 20 20:52:46 2016 -0400
.\"
.\" 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: April 25 2018 $
.Dt D2I_ASN1_OBJECT 3
.Os
.Sh NAME
.Nm d2i_ASN1_OBJECT ,
.Nm i2d_ASN1_OBJECT
.Nd decode and encode ASN.1 object identifiers
.Sh SYNOPSIS
.In openssl/asn1.h
.Ft ASN1_OBJECT *
.Fo d2i_ASN1_OBJECT
.Fa "ASN1_OBJECT **val_out"
.Fa "unsigned char **der_in"
.Fa "long length"
.Fc
.Ft int
.Fo i2d_ASN1_OBJECT
.Fa "const ASN1_OBJECT *val_in"
.Fa "unsigned char **der_out"
.Fc
.Sh DESCRIPTION
These functions decode and encode ASN.1 object identifiers.
For details about the semantics, examples, caveats, and bugs, see
.Xr ASN1_item_d2i 3 .
.Pp
The objects returned from
.Fn d2i_ASN1_OBJECT
and the data contained in them are always marked as dynamically
allocated, so when they are no longer needed,
.Xr ASN1_OBJECT_free 3
can be called on them.
.Pp
If reusing an existing object is attempted but the
.Pf * Fa val_out
passed in points to an object that is not marked as dynamically
allocated, then the existing object is left untouched and
.Fn d2i_ASN1_OBJECT
behaves as if
.Pf * Fa val_out
would have been
.Dv NULL :
A new object is allocated and a pointer to it is both stored in
.Pf * Fa val_out
and returned.
.Sh RETURN VALUES
.Fn d2i_ASN1_OBJECT
returns an
.Vt ASN1_OBJECT
object or
.Dv NULL
if an error occurs.
.Pp
.Fn i2d_ASN1_OBJECT
returns the number of bytes successfully encoded
or a value <= 0 if an error occurs.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr ASN1_OBJECT_new 3 ,
.Xr OBJ_nid2obj 3
.Sh HISTORY
.Fn d2i_ASN1_OBJECT
and
.Fn i2d_ASN1_OBJECT
first appeared in SSLeay 0.5.1 and have been available since
.Ox 2.4 .
.Sh CAVEATS
.Fn d2i_ASN1_OBJECT
never sets the long and short names of the object, not even if the
object identifier matches one that is built into the library.
To find the names of an object identifier parsed from DER or BER
input, call
.Xr OBJ_obj2nid 3
on the returned object, and then
.Xr OBJ_nid2sn 3
and
.Xr OBJ_nid2ln 3
on the result.
.Sh BUGS
When reusing a dynamically allocated object that contains dynamically
allocated names, the old names are not freed and the memory containing
them is leaked.