1.\" $OpenBSD: ASN1_item_pack.3,v 1.1 2021/11/15 11:51:09 schwarze Exp $ 2.\" 3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: November 15 2021 $ 18.Dt ASN1_ITEM_PACK 3 19.Os 20.Sh NAME 21.Nm ASN1_item_pack , 22.Nm ASN1_item_unpack 23.Nd pack an ASN.1 object into an ASN1_STRING 24.Sh SYNOPSIS 25.In openssl/asn1.h 26.Ft ASN1_STRING * 27.Fo ASN1_item_pack 28.Fa "void *val_in" 29.Fa "const ASN1_ITEM *it" 30.Fa "ASN1_STRING **string_out" 31.Fc 32.Ft void * 33.Fo ASN1_item_unpack 34.Fa "const ASN1_STRING *string_in" 35.Fa "const ASN1_ITEM *it" 36.Fc 37.Sh DESCRIPTION 38.Fn ASN1_item_pack 39encodes the object pointed to by 40.Fa val_in 41into DER format using 42.Xr ASN1_item_i2d 3 43and stores the encoded form in 44.Pf ** Fa string_out . 45If 46.Fa string_out 47or 48.Pf * Fa string_out 49is a 50.Dv NULL 51pointer, a new 52.Vt ASN1_STRING 53object is allocated and returned. 54.Pp 55.Fn ASN1_item_unpack 56interprets the data in 57.Fa string_in 58as a DER- or BER-encoded byte array and decodes one value of the type 59.Fa it 60into a newly allocated object using 61.Xr ASN1_item_d2i 3 . 62.Sh RETURN VALUES 63.Fn ASN1_item_pack 64returns the modified or new object or 65.Dv NULL 66if memory allocation or encoding fails. 67.Pp 68.Fn ASN1_item_unpack 69returns the new object or 70.Dv NULL 71if memory allocation or decoding fails. 72.Sh SEE ALSO 73.Xr ASN1_item_d2i 3 , 74.Xr ASN1_item_new 3 , 75.Xr ASN1_STRING_new 3 76.Sh HISTORY 77.Fn ASN1_item_pack 78and 79.Fn ASN1_item_unpack 80first appeared in OpenSSL 0.9.7 and have been available since 81.Ox 3.2 . 82.Sh BUGS 83See the BUGS section in 84.Xr ASN1_item_i2d 3 . 85