summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2018-02-12 15:45:12 +0000
committerschwarze <>2018-02-12 15:45:12 +0000
commit07fd0d6c60438241a541e714655b2213e0617433 (patch)
treedd86a4e7e1102496146be36c951908c0df779b8a
parent95150ccab60dc90f32fc3d09c09ba1af1ad6a112 (diff)
downloadopenbsd-07fd0d6c60438241a541e714655b2213e0617433.tar.gz
openbsd-07fd0d6c60438241a541e714655b2213e0617433.tar.bz2
openbsd-07fd0d6c60438241a541e714655b2213e0617433.zip
Add the missing RETURN VALUES section and reorder the content
accordingly. Make some statements more precise, and point out some dangerous traps in these ill-designed interfaces. Also do some minor polishing while here. Triggered by OpenSSL commit 1f13ad31 Dec 25 17:50:39 2017 +0800 by Paul Yang, but not using most of his wording because that is in part redundant, in part incomplete, and in part outright wrong.
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_length.3128
1 files changed, 93 insertions, 35 deletions
diff --git a/src/lib/libcrypto/man/ASN1_STRING_length.3 b/src/lib/libcrypto/man/ASN1_STRING_length.3
index 2c797481d7..398d49eee4 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_length.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_length.3
@@ -1,8 +1,26 @@
1.\" $OpenBSD: ASN1_STRING_length.3,v 1.6 2016/12/25 22:15:10 schwarze Exp $ 1.\" $OpenBSD: ASN1_STRING_length.3,v 1.7 2018/02/12 15:45:12 schwarze Exp $
2.\" OpenSSL 99d63d46 Tue Jun 21 07:03:34 2016 -0400 2.\" full merge up to: OpenSSL 99d63d46 Tue Jun 21 07:03:34 2016 -0400
3.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800
3.\" 4.\"
4.\" This file was written by Dr. Stephen Henson. 5.\" This file is a derived work.
5.\" Copyright (c) 2002, 2006, 2013, 2015, 2016 The OpenSSL Project. 6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson.
23.\" Copyright (c) 2002, 2006, 2013, 2015, 2016, 2017 The OpenSSL Project.
6.\" All rights reserved. 24.\" All rights reserved.
7.\" 25.\"
8.\" Redistribution and use in source and binary forms, with or without 26.\" Redistribution and use in source and binary forms, with or without
@@ -49,7 +67,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 69.\"
52.Dd $Mdocdate: December 25 2016 $ 70.Dd $Mdocdate: February 12 2018 $
53.Dt ASN1_STRING_LENGTH 3 71.Dt ASN1_STRING_LENGTH 3
54.Os 72.Os
55.Sh NAME 73.Sh NAME
@@ -107,27 +125,24 @@ These functions manipulate
107structures. 125structures.
108.Pp 126.Pp
109.Fn ASN1_STRING_cmp 127.Fn ASN1_STRING_cmp
110compares 128compares the type, the length, and the content of
111.Fa a 129.Fa a
112and 130and
113.Fa b 131.Fa b .
114and returns 0 if the two are identical.
115The string types and the content are compared.
116.Pp 132.Pp
117.Fn ASN1_STRING_data 133.Fn ASN1_STRING_data
118returns an internal pointer to the data of 134returns an internal pointer to the data of
119.Fa x . 135.Fa x .
120Since this is an internal pointer, it should 136It should not be freed or modified in any way.
121.Em not
122be freed or modified in any way.
123.Pp 137.Pp
124.Fn ASN1_STRING_dup 138.Fn ASN1_STRING_dup
125returns a copy of the structure 139copies
126.Fa a . 140.Fa a .
127.Pp 141.Pp
128.Fn ASN1_STRING_length 142.Fn ASN1_STRING_length
129returns the length of the content of 143returns the length attribute of
130.Fa x . 144.Fa x ,
145measured in bytes.
131.Pp 146.Pp
132.Fn ASN1_STRING_length_set 147.Fn ASN1_STRING_length_set
133sets the length attribute of 148sets the length attribute of
@@ -139,39 +154,46 @@ It may put
139into an inconsistent internal state. 154into an inconsistent internal state.
140.Pp 155.Pp
141.Fn ASN1_STRING_set 156.Fn ASN1_STRING_set
142sets the data of the string 157sets the length attribute of
143.Fa str 158.Fa str
144to the buffer 159to
160.Fa len
161and copies that number of bytes from
145.Fa data 162.Fa data
146of length 163into
164.Fa str .
165If
166.Fa len
167is -1, then
168.Fn strlen data
169is used instead of
147.Fa len . 170.Fa len .
148The supplied data is copied.
149If 171If
172.Fa data
173is
174.Dv NULL ,
175the content of
176.Fa str
177remains uninitialized; that is not considered an error unless
150.Fa len 178.Fa len
151is -1 then the length is determined by 179is negative.
152.Fn strlen data .
153.Pp 180.Pp
154.Fn ASN1_STRING_to_UTF8 181.Fn ASN1_STRING_to_UTF8
155converts the string 182converts the string
156.Fa in 183.Fa in
157to UTF8 format. 184to UTF-8 format.
158The converted data is copied into a newly allocated buffer 185The converted data is copied into a newly allocated buffer
159.Fa out . 186.Pf * Fa out .
160The length of
161.Fa out
162is returned or a negative error code.
163The buffer 187The buffer
164.Fa out 188.Pf * Fa out
165should be freed using 189should be freed using
166.Xr free 3 . 190.Xr free 3 .
167.Pp 191.Pp
168.Fn ASN1_STRING_type 192.Fn ASN1_STRING_type
169returns the type of 193returns the type of
170.Fa x , 194.Fa x .
171using standard constants such as
172.Dv V_ASN1_OCTET_STRING .
173.Pp 195.Pp
174Almost all ASN.1 types in OpenSSL are represented as 196Almost all ASN.1 types are represented as
175.Vt ASN1_STRING 197.Vt ASN1_STRING
176structures. 198structures.
177Other types such as 199Other types such as
@@ -200,17 +222,53 @@ be used instead.
200In general it cannot be assumed that the data returned by 222In general it cannot be assumed that the data returned by
201.Fn ASN1_STRING_data 223.Fn ASN1_STRING_data
202is NUL terminated, and it may contain embedded NUL characters. 224is NUL terminated, and it may contain embedded NUL characters.
203The actual format of the data will depend on the actual string type itself: 225The format of the data depends on the string type:
204for example for an 226for example for an
205.Vt IA5String 227.Vt IA5String
206the data will be ASCII, for a 228the data contains ASCII characters, a
207.Vt BMPString 229.Vt BMPString
208two bytes per character in big endian format, and a 230two bytes per character in big endian format, and a
209.Vt UTF8String 231.Vt UTF8String
210will be in UTF8 format. 232UTF-8 characters.
211.Pp 233.Pp
212Similar care should be take to ensure the data is in the correct format 234Similar care should be taken to ensure the data is in the correct format
213when calling 235when calling
214.Fn ASN1_STRING_set . 236.Fn ASN1_STRING_set .
237.Sh RETURN VALUES
238.Fn ASN1_STRING_cmp
239returns 0 if the type, the length, and the content of
240.Fa a
241and
242.Fa b
243agree, or a non-zero value otherwise.
244In contrast to
245.Xr strcmp 3 ,
246the sign of the return value does not indicate lexicographical ordering.
247.Pp
248.Fn ASN1_STRING_data
249returns an internal pointer to the data of
250.Fa x .
251.Pp
252.Fn ASN1_STRING_dup
253returns a pointer to a newly allocated
254.Vt ASN1_STRING
255structure or
256.Dv NULL
257if an error occurred.
258.Pp
259.Fn ASN1_STRING_length
260returns a number of bytes.
261.Pp
262.Fn ASN1_STRING_set
263returns 1 on success or 0 on failure.
264.Pp
265.Fn ASN1_STRING_to_UTF8
266returns the number of bytes in the output buffer
267.Pf * Fa out ,
268or a negative number if an error occurred.
269.Pp
270.Fn ASN1_STRING_type
271returns an integer constant, for example
272.Dv V_ASN1_OCTET_STRING .
215.Sh SEE ALSO 273.Sh SEE ALSO
216.Xr ERR_get_error 3 274.Xr ERR_get_error 3