From 1dfa989674c3d00414647d647fa08ad8146a4cad Mon Sep 17 00:00:00 2001 From: schwarze <> Date: Wed, 4 Jan 2017 09:04:45 +0000 Subject: Complete rewrite: Better one-line description. Specify the correct header file. Same parameter names as in ASN1_item_d2i(3). Lots of new information. The ASN1_OBJECT interfaces appear specifically designed to maximize the number and subtlety of traps, maybe in order to trap the wary along with the unwary. All the quirks, caveats, and bugs of ASN1_item_d2i(3) apply, and there are three additional ones on top in this page. It looks like that design approach was so successful that the designers managed to trap even themselves: see the new BUGS section. --- src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 | 130 ++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 index 77e6848394..7098c774f0 100644 --- a/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 +++ b/src/lib/libcrypto/man/d2i_ASN1_OBJECT.3 @@ -1,78 +1,92 @@ -.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.4 2016/12/08 20:22:08 jmc Exp $ +.\" $OpenBSD: d2i_ASN1_OBJECT.3,v 1.5 2017/01/04 09:04:45 schwarze Exp $ .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" -.\" This file was written by Dr. Stephen Henson . -.\" Copyright (c) 2002, 2015 The OpenSSL Project. All rights reserved. +.\" Copyright (c) 2017 Ingo Schwarze .\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: +.\" 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. .\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. +.\" 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. .\" -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" -.\" 3. All advertising materials mentioning features or use of this -.\" software must display the following acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" -.\" -.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to -.\" endorse or promote products derived from this software without -.\" prior written permission. For written permission, please contact -.\" openssl-core@openssl.org. -.\" -.\" 5. Products derived from this software may not be called "OpenSSL" -.\" nor may "OpenSSL" appear in their names without prior written -.\" permission of the OpenSSL Project. -.\" -.\" 6. Redistributions of any form whatsoever must retain the following -.\" acknowledgment: -.\" "This product includes software developed by the OpenSSL Project -.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY -.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR -.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -.\" OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 8 2016 $ +.Dd $Mdocdate: January 4 2017 $ .Dt D2I_ASN1_OBJECT 3 .Os .Sh NAME .Nm d2i_ASN1_OBJECT , .Nm i2d_ASN1_OBJECT -.Nd ASN.1 OBJECT IDENTIFIER functions +.Nd decode and encode ASN.1 object identifiers .Sh SYNOPSIS -.In openssl/objects.h +.In openssl/asn1.h .Ft ASN1_OBJECT * .Fo d2i_ASN1_OBJECT -.Fa "ASN1_OBJECT **a" -.Fa "unsigned char **pp" +.Fa "ASN1_OBJECT **val_out" +.Fa "unsigned char **der_in" .Fa "long length" .Fc .Ft int .Fo i2d_ASN1_OBJECT -.Fa "ASN1_OBJECT *a" -.Fa "unsigned char **pp" +.Fa "ASN1_OBJECT *val_in" +.Fa "unsigned char **der_out" .Fc .Sh DESCRIPTION -These functions decode and encode an ASN.1 OBJECT IDENTIFIER. -They otherwise behave in a similar way to -.Xr d2i_X509 3 -and -.Xr i2d_X509 3 . +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 d2i_X509 3 +.Xr ASN1_item_d2i 3 , +.Xr ASN1_OBJECT_new 3 , +.Xr OBJ_nid2obj 3 +.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-in to 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. -- cgit v1.2.3-55-g6feb