.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.13 2022/09/12 14:33:47 tb Exp $ .\" .\" Copyright (c) 2017, 2022 Ingo Schwarze .\" .\" 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: September 12 2022 $ .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 LibreSSL implementation of .Fn d2i_ASN1_OBJECT always calls .Xr ASN1_OBJECT_free 3 if an existing object is passed in via .Fa val_out and it always creates a new object from scratch. Other implementations may attempt to reuse an existing object, which is fragile and prone to bugs. Consequently, always passing .Dv NULL for the .Fa val_out argument is recommended. .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. .Sh RETURN VALUES .Fn d2i_ASN1_OBJECT returns a pointer to the new .Vt ASN1_OBJECT object or .Dv NULL if an error occurs. With other implementations, it might return a pointer to the reused .Vt ASN1_OBJECT . .Pp .Fn i2d_ASN1_OBJECT returns the number of bytes successfully encoded or a value <= 0 if an error occurs. .Sh SEE ALSO .Xr a2d_ASN1_OBJECT 3 , .Xr ASN1_item_d2i 3 , .Xr ASN1_OBJECT_new 3 , .Xr OBJ_nid2obj 3 .Sh STANDARDS ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER), section 8.19: Encoding of an object identifier value .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.