summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/ASN1_item_pack.3
blob: 4c87530622ff9c2fd038c927f77e48f590bfcea0 (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
.\" $OpenBSD: ASN1_item_pack.3,v 1.1 2021/11/15 11:51:09 schwarze Exp $
.\"
.\" Copyright (c) 2021 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: November 15 2021 $
.Dt ASN1_ITEM_PACK 3
.Os
.Sh NAME
.Nm ASN1_item_pack ,
.Nm ASN1_item_unpack
.Nd pack an ASN.1 object into an ASN1_STRING
.Sh SYNOPSIS
.In openssl/asn1.h
.Ft ASN1_STRING *
.Fo ASN1_item_pack
.Fa "void *val_in"
.Fa "const ASN1_ITEM *it"
.Fa "ASN1_STRING **string_out"
.Fc
.Ft void *
.Fo ASN1_item_unpack
.Fa "const ASN1_STRING *string_in"
.Fa "const ASN1_ITEM *it"
.Fc
.Sh DESCRIPTION
.Fn ASN1_item_pack
encodes the object pointed to by
.Fa val_in
into DER format using
.Xr ASN1_item_i2d 3
and stores the encoded form in
.Pf ** Fa string_out .
If
.Fa string_out
or
.Pf * Fa string_out
is a
.Dv NULL
pointer, a new
.Vt ASN1_STRING
object is allocated and returned.
.Pp
.Fn ASN1_item_unpack
interprets the data in
.Fa string_in
as a DER- or BER-encoded byte array and decodes one value of the type
.Fa it
into a newly allocated object using
.Xr ASN1_item_d2i 3 .
.Sh RETURN VALUES
.Fn ASN1_item_pack
returns the modified or new object or
.Dv NULL
if memory allocation or encoding fails.
.Pp
.Fn ASN1_item_unpack
returns the new object or
.Dv NULL
if memory allocation or decoding fails.
.Sh SEE ALSO
.Xr ASN1_item_d2i 3 ,
.Xr ASN1_item_new 3 ,
.Xr ASN1_STRING_new 3
.Sh HISTORY
.Fn ASN1_item_pack
and
.Fn ASN1_item_unpack
first appeared in OpenSSL 0.9.7 and have been available since
.Ox 3.2 .
.Sh BUGS
See the BUGS section in
.Xr ASN1_item_i2d 3 .