summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2017-01-03 20:15:47 +0000
committerschwarze <>2017-01-03 20:15:47 +0000
commitfff8af46ac88307060ab4cbdda99dab49bfa1728 (patch)
tree9115c6517bef9bf4b4021cfbfac5340bbaccd455 /src
parentfd81cf8bba7723f40b391937f8ff671f2526d90c (diff)
downloadopenbsd-fff8af46ac88307060ab4cbdda99dab49bfa1728.tar.gz
openbsd-fff8af46ac88307060ab4cbdda99dab49bfa1728.tar.bz2
openbsd-fff8af46ac88307060ab4cbdda99dab49bfa1728.zip
Document ASN1_TYPE_new(3) and ASN1_TYPE_free(3), even though OpenSSL
does not document them. By being in <openssl/asn1.h>, they are public, and it makes no sense to document accessors but not document constructors and destructors. Improve the one-line description. Mention various missing details. Many wording improvements. Add some cross references.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/man/ASN1_TYPE_get.3134
-rw-r--r--src/lib/libcrypto/man/ASN1_item_new.36
2 files changed, 106 insertions, 34 deletions
diff --git a/src/lib/libcrypto/man/ASN1_TYPE_get.3 b/src/lib/libcrypto/man/ASN1_TYPE_get.3
index 5531e572d1..47ea1cdfc6 100644
--- a/src/lib/libcrypto/man/ASN1_TYPE_get.3
+++ b/src/lib/libcrypto/man/ASN1_TYPE_get.3
@@ -1,7 +1,24 @@
1.\" $OpenBSD: ASN1_TYPE_get.3,v 1.2 2016/11/12 19:23:16 jmc Exp $ 1.\" $OpenBSD: ASN1_TYPE_get.3,v 1.3 2017/01/03 20:15:47 schwarze Exp $
2.\" OpenSSL 99d63d46 Mon Jun 6 00:43:05 2016 -0400 2.\" OpenSSL 99d63d46 Mon Jun 6 00:43:05 2016 -0400
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved. 22.\" Copyright (c) 2015, 2016 The OpenSSL Project. All rights reserved.
6.\" 23.\"
7.\" Redistribution and use in source and binary forms, with or without 24.\" Redistribution and use in source and binary forms, with or without
@@ -48,17 +65,23 @@
48.\" 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
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 67.\"
51.Dd $Mdocdate: November 12 2016 $ 68.Dd $Mdocdate: January 3 2017 $
52.Dt ASN1_TYPE_GET 3 69.Dt ASN1_TYPE_GET 3
53.Os 70.Os
54.Sh NAME 71.Sh NAME
72.Nm ASN1_TYPE_new ,
73.Nm ASN1_TYPE_free ,
55.Nm ASN1_TYPE_get , 74.Nm ASN1_TYPE_get ,
56.Nm ASN1_TYPE_set , 75.Nm ASN1_TYPE_set ,
57.Nm ASN1_TYPE_set1 , 76.Nm ASN1_TYPE_set1 ,
58.Nm ASN1_TYPE_cmp 77.Nm ASN1_TYPE_cmp
59.Nd ASN1_TYPE utility functions 78.Nd ASN.1 objects of arbitrary type
60.Sh SYNOPSIS 79.Sh SYNOPSIS
61.In openssl/asn1.h 80.In openssl/asn1.h
81.Ft ASN1_TYPE *
82.Fn ASN1_TYPE_new void
83.Ft void
84.Fn ASN1_TYPE_free "ASN1_TYPE *a"
62.Ft int 85.Ft int
63.Fo ASN1_TYPE_get 86.Fo ASN1_TYPE_get
64.Fa "ASN1_TYPE *a" 87.Fa "ASN1_TYPE *a"
@@ -81,20 +104,41 @@
81.Fa "ASN1_TYPE *b" 104.Fa "ASN1_TYPE *b"
82.Fc 105.Fc
83.Sh DESCRIPTION 106.Sh DESCRIPTION
84These functions manipulate
85.Vt ASN1_TYPE 107.Vt ASN1_TYPE
86structures. 108represents the ASN.1 ANY type.
87An 109An
88.Vt ASN1_TYPE 110.Vt ASN1_TYPE
89structure can contain any ASN.1 type or constructed type such as a 111object can store an ASN.1 value of arbitrary type,
90SEQUENCE: it is effectively equivalent to the ASN.1 ANY type. 112including constructed types such as a SEQUENCE.
113It also remembers internally which type it currently holds.
114.Pp
115.Fn ASN1_TYPE_new
116allocates and initializes an empty
117.Vt ASN1_TYPE
118object of undefined type.
119.Pp
120.Fn ASN1_TYPE_free
121frees
122.Fa a
123including the value stored in it, if any.
124If
125.Fa a
126is a
127.Dv NULL
128pointer, no action occurs.
91.Pp 129.Pp
92.Fn ASN1_TYPE_get 130.Fn ASN1_TYPE_get
93returns the type of 131returns the type of
94.Fa a . 132.Fa a ,
133represented by one of the
134.Dv V_ASN1_*
135constants defined in
136.In openssl/asn1.h .
95.Pp 137.Pp
96.Fn ASN1_TYPE_set 138.Fn ASN1_TYPE_set
97sets the value of 139frees the value contained in
140.Fa a ,
141if any, and sets
98.Fa a 142.Fa a
99to 143to
100.Fa type 144.Fa type
@@ -107,28 +151,28 @@ internally so it must
107be freed up after the call. 151be freed up after the call.
108.Pp 152.Pp
109.Fn ASN1_TYPE_set1 153.Fn ASN1_TYPE_set1
110sets the value of 154sets the type of
111.Fa a 155.Fa a
112to 156to
113.Fa type 157.Fa type
114and a copy of 158and its value to a copy of
115.Fa value . 159.Fa value .
116.Pp 160If copying succeeds, the previous value that was contained in
117.Fn ASN1_TYPE_cmp
118compares ASN.1 types
119.Fa a 161.Fa a
120and 162is freed.
121.Fa b . 163If copying fails,
164.Fa a
165remains unchanged.
122.Pp 166.Pp
123The type and meaning of the 167The type and meaning of the
124.Fa value 168.Fa value
125parameter for 169argument of
126.Fn ASN1_TYPE_set 170.Fn ASN1_TYPE_set
127and 171and
128.Fn ASN1_TYPE_set1 172.Fn ASN1_TYPE_set1
129is determined by the 173is determined by the
130.Fa type 174.Fa type
131parameter. 175argument.
132If 176If
133.Fa type 177.Fa type
134is 178is
@@ -173,19 +217,26 @@ contains the entire ASN.1 encoding verbatim, including tag and
173length octets. 217length octets.
174.Pp 218.Pp
175.Fn ASN1_TYPE_cmp 219.Fn ASN1_TYPE_cmp
176may not return zero if two types are equivalent but have different 220checks that
177encodings. 221.Fa a
178For example the single content octet of the boolean TRUE value under BER 222and
179can have any non-zero encoding but 223.Fa b
224have the same type, the same value, and are encoded in the same way.
225.Pp
226If the types agree and the values have the same meaning but are
227encoded differently, they are considered different.
228For example, a boolean value is represented
229using a single content octet.
230Under BER, any non-zero octet represents the TRUE value, but
180.Fn ASN1_TYPE_cmp 231.Fn ASN1_TYPE_cmp
181will only return zero if the values are the same. 232will only report a match if the content octet is the same.
182.Pp 233.Pp
183If either or both of the parameters passed to 234If either or both of the arguments passed to
184.Fn ASN1_TYPE_cmp 235.Fn ASN1_TYPE_cmp
185is 236is
186.Dv NULL , 237.Dv NULL ,
187the return value is non-zero. 238the result is a mismatch.
188Technically, if both parameters are 239Technically, if both arguments are
189.Dv NULL , 240.Dv NULL ,
190the two types could be absent OPTIONAL fields and so should match, 241the two types could be absent OPTIONAL fields and so should match,
191however passing 242however passing
@@ -198,13 +249,32 @@ for types which do
198match. 249match.
199So applications should handle the case of two absent values separately. 250So applications should handle the case of two absent values separately.
200.Sh RETURN VALUES 251.Sh RETURN VALUES
201.Fn ASN1_TYPE_get 252.Fn ASN1_TYPE_new
202returns the type of the 253returns the new
203.Vt ASN1_TYPE 254.Vt ASN1_TYPE
204argument. 255object or
256.Dv NULL
257if an error occurs.
258.Pp
259.Fn ASN1_TYPE_get
260returns the type of
261.Fa a
262or 0 if an error occurs.
263The latter can happen if
264.Fa a
265does not contain a value even though its type is not
266.Dv V_ASN1_NULL .
267For example, it will always happen for empty objects
268newly constructed with
269.Fn ASN1_TYPE_new .
205.Pp 270.Pp
206.Fn ASN1_TYPE_set1 271.Fn ASN1_TYPE_set1
207returns 1 for success or 0 for failure. 272returns 1 if the copying succeeds or 0 if it fails.
208.Pp 273.Pp
209.Fn ASN1_TYPE_cmp 274.Fn ASN1_TYPE_cmp
210returns 0 if the types are identical or non-zero otherwise. 275returns 0 for a match or non-zero for a mismatch.
276.Sh SEE ALSO
277.Xr ASN1_item_free 3 ,
278.Xr ASN1_STRING_dup 3 ,
279.Xr d2i_ASN1_TYPE 3 ,
280.Xr OBJ_dup 3
diff --git a/src/lib/libcrypto/man/ASN1_item_new.3 b/src/lib/libcrypto/man/ASN1_item_new.3
index 0444bbe15a..e679815751 100644
--- a/src/lib/libcrypto/man/ASN1_item_new.3
+++ b/src/lib/libcrypto/man/ASN1_item_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_item_new.3,v 1.1 2016/12/24 21:42:29 schwarze Exp $ 1.\" $OpenBSD: ASN1_item_new.3,v 1.2 2017/01/03 20:15:47 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
@@ -14,7 +14,7 @@
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\" 16.\"
17.Dd $Mdocdate: December 24 2016 $ 17.Dd $Mdocdate: January 3 2017 $
18.Dt ASN1_ITEM_NEW 3 18.Dt ASN1_ITEM_NEW 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
@@ -95,6 +95,8 @@ object or
95if an error occurs. 95if an error occurs.
96.Sh SEE ALSO 96.Sh SEE ALSO
97.Xr ASN1_item_d2i 3 , 97.Xr ASN1_item_d2i 3 ,
98.Xr ASN1_TYPE_new 3 ,
99.Xr d2i_ASN1_NULL 3 ,
98.Xr OBJ_nid2obj 3 100.Xr OBJ_nid2obj 3
99.Sh BUGS 101.Sh BUGS
100The 102The