summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2017-01-03 23:56:50 +0000
committerschwarze <>2017-01-03 23:56:50 +0000
commit38354d6effee546e2cc9f9a651d007c0611a0ae0 (patch)
tree036464cd3baefd049017595d76762a63e8c75891 /src
parent916f67db780ccd3eb89983a487b07f27846ea260 (diff)
downloadopenbsd-38354d6effee546e2cc9f9a651d007c0611a0ae0.tar.gz
openbsd-38354d6effee546e2cc9f9a651d007c0611a0ae0.tar.bz2
openbsd-38354d6effee546e2cc9f9a651d007c0611a0ae0.zip
Document d2i_ASN1_TYPE(3) and i2d_ASN1_TYPE(3),
both listed in <openssl/asn1.h> and in OpenSSL doc/man3/d2i_X509.pod. Minor wording improvements while here.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/ASN1_item_d2i.355
1 files changed, 46 insertions, 9 deletions
diff --git a/src/lib/libcrypto/man/ASN1_item_d2i.3 b/src/lib/libcrypto/man/ASN1_item_d2i.3
index afdd234c23..4bdaf4bad4 100644
--- a/src/lib/libcrypto/man/ASN1_item_d2i.3
+++ b/src/lib/libcrypto/man/ASN1_item_d2i.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_d2i.3,v 1.3 2016/12/27 08:20:27 jmc Exp $ 1.\" $OpenBSD: ASN1_item_d2i.3,v 1.4 2017/01/03 23:56:50 schwarze Exp $
2.\" OpenSSL doc/man3/d2i_X509.pod b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL doc/man3/d2i_X509.pod b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file is a derived work. 4.\" This file is a derived work.
@@ -65,16 +65,18 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 67.\"
68.Dd $Mdocdate: December 27 2016 $ 68.Dd $Mdocdate: January 3 2017 $
69.Dt ASN1_ITEM_D2I 3 69.Dt ASN1_ITEM_D2I 3
70.Os 70.Os
71.Sh NAME 71.Sh NAME
72.Nm ASN1_item_d2i , 72.Nm ASN1_item_d2i ,
73.Nm ASN1_item_d2i_bio , 73.Nm ASN1_item_d2i_bio ,
74.Nm ASN1_item_d2i_fp , 74.Nm ASN1_item_d2i_fp ,
75.Nm d2i_ASN1_TYPE ,
75.Nm ASN1_item_i2d , 76.Nm ASN1_item_i2d ,
76.Nm ASN1_item_i2d_bio , 77.Nm ASN1_item_i2d_bio ,
77.Nm ASN1_item_i2d_fp , 78.Nm ASN1_item_i2d_fp ,
79.Nm i2d_ASN1_TYPE ,
78.Nm ASN1_item_dup , 80.Nm ASN1_item_dup ,
79.Nm ASN1_item_print 81.Nm ASN1_item_print
80.Nd decode and encode ASN.1 objects 82.Nd decode and encode ASN.1 objects
@@ -99,6 +101,12 @@
99.Fa "FILE *in_fp" 101.Fa "FILE *in_fp"
100.Fa "void *val_out" 102.Fa "void *val_out"
101.Fc 103.Fc
104.Ft ASN1_TYPE *
105.Fo d2i_ASN1_TYPE
106.Fa "ASN1_TYPE **val_out"
107.Fa "const unsigned char **der_in"
108.Fa "long length"
109.Fc
102.Ft int 110.Ft int
103.Fo ASN1_item_i2d 111.Fo ASN1_item_i2d
104.Fa "ASN1_VALUE *val_in" 112.Fa "ASN1_VALUE *val_in"
@@ -117,6 +125,11 @@
117.Fa "FILE *out_fp" 125.Fa "FILE *out_fp"
118.Fa "void *val_in" 126.Fa "void *val_in"
119.Fc 127.Fc
128.Ft int
129.Fo i2d_ASN1_TYPE
130.Fa "ASN1_TYPE *val_in"
131.Fa "unsigned char **der_out"
132.Fc
120.Ft void * 133.Ft void *
121.Fo ASN1_item_dup 134.Fo ASN1_item_dup
122.Fa "const ASN1_ITEM *it" 135.Fa "const ASN1_ITEM *it"
@@ -131,19 +144,21 @@
131.Fa "const ASN1_PCTX *pctx" 144.Fa "const ASN1_PCTX *pctx"
132.Fc 145.Fc
133.Sh DESCRIPTION 146.Sh DESCRIPTION
134These functions convert ASN.1 values from their DER encoding to 147These functions convert ASN.1 values from their BER encoding to
135internal C structures 148internal C structures
136.Pq Dq d2i 149.Pq Dq d2i
137and vice versa 150and vice versa
138.Pq Dq i2d . 151.Pq Dq i2d .
139Unlike the C structures which contain pointers to sub-objects, DER 152Unlike the C structures which contain pointers to sub-objects, BER
140is a serialized encoding, suitable for transfer over the network 153is a serialized encoding, suitable for transfer over the network
141and for storage in a file. 154and for storage in a file.
142.Pp 155.Pp
143.Fn ASN1_item_d2i 156.Fn ASN1_item_d2i
144interpretes 157interpretes
145.Pf * Fa der_in 158.Pf * Fa der_in
146as a DER- or BER-encoded byte array and decodes 159as a DER- or BER-encoded byte array and decodes one value of type
160.Fa it
161represented by up to
147.Fa length 162.Fa length
148bytes. 163bytes.
149If successful, 164If successful,
@@ -187,6 +202,14 @@ or
187.Vt FILE , 202.Vt FILE ,
188respectively. 203respectively.
189.Pp 204.Pp
205.Fn d2i_ASN1_TYPE
206is similar to
207.Fn ASN1_item_d2i
208except that it does not require a desired type to be specified by
209the user, but instead returns an
210.Vt ASN1_TYPE
211wrapper object containing both the type and the value found in the input.
212.Pp
190.Fn ASN1_item_i2d 213.Fn ASN1_item_i2d
191encodes the object pointed to by 214encodes the object pointed to by
192.Fa val_in 215.Fa val_in
@@ -239,6 +262,14 @@ or
239.Vt FILE , 262.Vt FILE ,
240respectively. 263respectively.
241.Pp 264.Pp
265.Fn i2d_ASN1_TYPE
266is similar to
267.Fn ASN1_item_i2d
268except that the type and the value are not provided separately,
269but in the form of a single
270.Vt ASN1_TYPE
271object.
272.Pp
242.Fn ASN1_item_dup 273.Fn ASN1_item_dup
243creates a deep copy of 274creates a deep copy of
244.Fa val_in 275.Fa val_in
@@ -250,8 +281,9 @@ and
250If successful, 281If successful,
251.Fn ASN1_item_d2i , 282.Fn ASN1_item_d2i ,
252.Fn ASN1_item_d2i_bio , 283.Fn ASN1_item_d2i_bio ,
284.Fn ASN1_item_d2i_fp ,
253and 285and
254.Fn ASN1_item_d2i_fp 286.Fn d2i_ASN1_TYPE
255return a pointer to the decoded ASN.1 value. 287return a pointer to the decoded ASN.1 value.
256In addition, if 288In addition, if
257.Fa val_out 289.Fa val_out
@@ -264,7 +296,9 @@ If an error occurs,
264is returned. 296is returned.
265.Pp 297.Pp
266.Fn ASN1_item_i2d 298.Fn ASN1_item_i2d
267returns the number of bytes written 299and
300.Fn i2d_ASN1_TYPE
301return the number of bytes written
268or a negative value if an error occurs. 302or a negative value if an error occurs.
269.Pp 303.Pp
270.Fn ASN1_item_i2d_bio 304.Fn ASN1_item_i2d_bio
@@ -282,7 +316,9 @@ if an error occurs.
282Many type-specific wrapper functions exist. 316Many type-specific wrapper functions exist.
283Using those wrappers is recommended in application code 317Using those wrappers is recommended in application code
284because it restores part of the type safety that the low-level 318because it restores part of the type safety that the low-level
285interfaces described in the present manual page lack. 319interfaces using
320.Vt ASN1_VALUE
321lack.
286.Pp 322.Pp
287For example, to allocate a buffer and write the DER encoding of an 323For example, to allocate a buffer and write the DER encoding of an
288.Vt X509 324.Vt X509
@@ -325,7 +361,8 @@ if (d2i_X509(&x, &p, len) == NULL)
325 /* error */ 361 /* error */
326.Ed 362.Ed
327.Sh SEE ALSO 363.Sh SEE ALSO
328.Xr ASN1_item_new 3 364.Xr ASN1_item_new 3 ,
365.Xr ASN1_TYPE_new 3
329.Sh CAVEATS 366.Sh CAVEATS
330If the type described by 367If the type described by
331.Fa it 368.Fa it