xref: /openbsd/lib/libcrypto/man/d2i_ASN1_OBJECT.3 (revision 09467b48)
1.\"	$OpenBSD: d2i_ASN1_OBJECT.3,v 1.9 2018/04/25 15:17:52 schwarze Exp $
2.\"	OpenSSL 05ea606a May 20 20:52:46 2016 -0400
3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: April 25 2018 $
19.Dt D2I_ASN1_OBJECT 3
20.Os
21.Sh NAME
22.Nm d2i_ASN1_OBJECT ,
23.Nm i2d_ASN1_OBJECT
24.Nd decode and encode ASN.1 object identifiers
25.Sh SYNOPSIS
26.In openssl/asn1.h
27.Ft ASN1_OBJECT *
28.Fo d2i_ASN1_OBJECT
29.Fa "ASN1_OBJECT **val_out"
30.Fa "unsigned char **der_in"
31.Fa "long length"
32.Fc
33.Ft int
34.Fo i2d_ASN1_OBJECT
35.Fa "const ASN1_OBJECT *val_in"
36.Fa "unsigned char **der_out"
37.Fc
38.Sh DESCRIPTION
39These functions decode and encode ASN.1 object identifiers.
40For details about the semantics, examples, caveats, and bugs, see
41.Xr ASN1_item_d2i 3 .
42.Pp
43The objects returned from
44.Fn d2i_ASN1_OBJECT
45and the data contained in them are always marked as dynamically
46allocated, so when they are no longer needed,
47.Xr ASN1_OBJECT_free 3
48can be called on them.
49.Pp
50If reusing an existing object is attempted but the
51.Pf * Fa val_out
52passed in points to an object that is not marked as dynamically
53allocated, then the existing object is left untouched and
54.Fn d2i_ASN1_OBJECT
55behaves as if
56.Pf * Fa val_out
57would have been
58.Dv NULL :
59A new object is allocated and a pointer to it is both stored in
60.Pf * Fa val_out
61and returned.
62.Sh RETURN VALUES
63.Fn d2i_ASN1_OBJECT
64returns an
65.Vt ASN1_OBJECT
66object or
67.Dv NULL
68if an error occurs.
69.Pp
70.Fn i2d_ASN1_OBJECT
71returns the number of bytes successfully encoded
72or a value <= 0 if an error occurs.
73.Sh SEE ALSO
74.Xr ASN1_item_d2i 3 ,
75.Xr ASN1_OBJECT_new 3 ,
76.Xr OBJ_nid2obj 3
77.Sh HISTORY
78.Fn d2i_ASN1_OBJECT
79and
80.Fn i2d_ASN1_OBJECT
81first appeared in SSLeay 0.5.1 and have been available since
82.Ox 2.4 .
83.Sh CAVEATS
84.Fn d2i_ASN1_OBJECT
85never sets the long and short names of the object, not even if the
86object identifier matches one that is built into the library.
87To find the names of an object identifier parsed from DER or BER
88input, call
89.Xr OBJ_obj2nid 3
90on the returned object, and then
91.Xr OBJ_nid2sn 3
92and
93.Xr OBJ_nid2ln 3
94on the result.
95.Sh BUGS
96When reusing a dynamically allocated object that contains dynamically
97allocated names, the old names are not freed and the memory containing
98them is leaked.
99