summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/ASN1_STRING_length.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/ASN1_STRING_length.3')
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_length.3358
1 files changed, 0 insertions, 358 deletions
diff --git a/src/lib/libcrypto/man/ASN1_STRING_length.3 b/src/lib/libcrypto/man/ASN1_STRING_length.3
deleted file mode 100644
index b87cf9987c..0000000000
--- a/src/lib/libcrypto/man/ASN1_STRING_length.3
+++ /dev/null
@@ -1,358 +0,0 @@
1.\" $OpenBSD: ASN1_STRING_length.3,v 1.20 2019/08/26 07:59:02 schwarze Exp $
2.\" full merge up to: OpenSSL 4a56d2a3 Feb 25 16:49:27 2018 +0300
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2019 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.
22.\" Copyright (c) 2002, 2006, 2013, 2015, 2016, 2017 The OpenSSL Project.
23.\" All rights reserved.
24.\"
25.\" Redistribution and use in source and binary forms, with or without
26.\" modification, are permitted provided that the following conditions
27.\" are met:
28.\"
29.\" 1. Redistributions of source code must retain the above copyright
30.\" notice, this list of conditions and the following disclaimer.
31.\"
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\" notice, this list of conditions and the following disclaimer in
34.\" the documentation and/or other materials provided with the
35.\" distribution.
36.\"
37.\" 3. All advertising materials mentioning features or use of this
38.\" software must display the following acknowledgment:
39.\" "This product includes software developed by the OpenSSL Project
40.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
41.\"
42.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
43.\" endorse or promote products derived from this software without
44.\" prior written permission. For written permission, please contact
45.\" openssl-core@openssl.org.
46.\"
47.\" 5. Products derived from this software may not be called "OpenSSL"
48.\" nor may "OpenSSL" appear in their names without prior written
49.\" permission of the OpenSSL Project.
50.\"
51.\" 6. Redistributions of any form whatsoever must retain the following
52.\" acknowledgment:
53.\" "This product includes software developed by the OpenSSL Project
54.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
55.\"
56.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
57.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
60.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
63.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
64.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
65.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\"
69.Dd $Mdocdate: August 26 2019 $
70.Dt ASN1_STRING_LENGTH 3
71.Os
72.Sh NAME
73.Nm ASN1_STRING_cmp ,
74.Nm ASN1_OCTET_STRING_cmp ,
75.Nm ASN1_STRING_data ,
76.Nm ASN1_STRING_dup ,
77.Nm ASN1_OCTET_STRING_dup ,
78.Nm ASN1_STRING_get0_data ,
79.Nm ASN1_STRING_length ,
80.Nm ASN1_STRING_length_set ,
81.Nm ASN1_STRING_set ,
82.Nm ASN1_OCTET_STRING_set ,
83.Nm ASN1_STRING_to_UTF8 ,
84.Nm ASN1_STRING_type
85.Nd ASN1_STRING utility functions
86.Sh SYNOPSIS
87.In openssl/asn1.h
88.Ft int
89.Fo ASN1_STRING_cmp
90.Fa "const ASN1_STRING *a"
91.Fa "const ASN1_STRING *b"
92.Fc
93.Ft int
94.Fo ASN1_OCTET_STRING_cmp
95.Fa "const ASN1_OCTET_STRING *a"
96.Fa "const ASN1_OCTET_STRING *b"
97.Fc
98.Ft unsigned char *
99.Fo ASN1_STRING_data
100.Fa "ASN1_STRING *x"
101.Fc
102.Ft ASN1_STRING *
103.Fo ASN1_STRING_dup
104.Fa "const ASN1_STRING *a"
105.Fc
106.Ft ASN1_OCTET_STRING *
107.Fo ASN1_OCTET_STRING_dup
108.Fa "const ASN1_OCTET_STRING *a"
109.Fc
110.Ft const unsigned char *
111.Fo ASN1_STRING_get0_data
112.Fa "const ASN1_STRING *x"
113.Fc
114.Ft int
115.Fo ASN1_STRING_length
116.Fa "const ASN1_STRING *x"
117.Fc
118.Ft void
119.Fo ASN1_STRING_length_set
120.Fa "ASN1_STRING *x"
121.Fa "int len"
122.Fc
123.Ft int
124.Fo ASN1_STRING_set
125.Fa "ASN1_STRING *str"
126.Fa "const void *data"
127.Fa "int len"
128.Fc
129.Ft int
130.Fo ASN1_OCTET_STRING_set
131.Fa "ASN1_OCTET_STRING *str"
132.Fa "const unsigned char *data"
133.Fa "int len"
134.Fc
135.Ft int
136.Fo ASN1_STRING_to_UTF8
137.Fa "unsigned char **out"
138.Fa "const ASN1_STRING *in"
139.Fc
140.Ft int
141.Fo ASN1_STRING_type
142.Fa "const ASN1_STRING *x"
143.Fc
144.Sh DESCRIPTION
145These functions manipulate
146.Vt ASN1_STRING
147structures.
148.Pp
149.Fn ASN1_STRING_cmp
150and
151.Fn ASN1_OCTET_STRING_cmp
152compare the type, the length, and the content of
153.Fa a
154and
155.Fa b .
156.Pp
157.Fn ASN1_STRING_data
158is similar to
159.Fn ASN1_STRING_get0_data
160except that the returned value is not constant.
161This function is deprecated.
162Applications should use
163.Fn ASN1_STRING_get0_data
164instead.
165.Pp
166.Fn ASN1_STRING_dup
167and
168.Fn ASN1_OCTET_STRING_dup
169copy
170.Fa a .
171.Pp
172.Fn ASN1_STRING_get0_data
173returns an internal pointer to the data of
174.Fa x .
175It should not be freed or modified in any way.
176.Pp
177.Fn ASN1_STRING_length
178returns the length attribute of
179.Fa x ,
180measured in bytes.
181.Pp
182.Fn ASN1_STRING_length_set
183sets the length attribute of
184.Fa x
185to
186.Fa len .
187It may put
188.Fa x
189into an inconsistent internal state.
190.Pp
191.Fn ASN1_STRING_set
192and
193.Fn ASN1_OCTET_STRING_set
194set the length attribute of
195.Fa str
196to
197.Fa len
198and copy that number of bytes from
199.Fa data
200into
201.Fa str .
202If
203.Fa len
204is -1, then
205.Fn strlen data
206is used instead of
207.Fa len .
208If
209.Fa data
210is
211.Dv NULL ,
212the content of
213.Fa str
214remains uninitialized; that is not considered an error unless
215.Fa len
216is negative.
217.Pp
218.Fn ASN1_STRING_to_UTF8
219converts the string
220.Fa in
221to UTF-8 format.
222The converted data is copied into a newly allocated buffer
223.Pf * Fa out .
224The buffer
225.Pf * Fa out
226should be freed using
227.Xr free 3 .
228.Pp
229.Fn ASN1_STRING_type
230returns the type of
231.Fa x .
232.Pp
233Almost all ASN.1 types are represented as
234.Vt ASN1_STRING
235structures.
236Other types such as
237.Vt ASN1_OCTET_STRING
238are simply typedefed to
239.Vt ASN1_STRING
240and the functions call the
241.Vt ASN1_STRING
242equivalents.
243.Vt ASN1_STRING
244is also used for some CHOICE types which consist entirely of primitive
245string types such as
246.Vt DirectoryString
247and
248.Vt Time .
249.Pp
250These functions should
251.Em not
252be used to examine or modify
253.Vt ASN1_INTEGER
254or
255.Vt ASN1_ENUMERATED
256types: the relevant INTEGER or ENUMERATED utility functions should
257be used instead.
258.Pp
259In general it cannot be assumed that the data returned by
260.Fn ASN1_STRING_get0_data
261and
262.Fn ASN1_STRING_data
263is NUL terminated, and it may contain embedded NUL characters.
264The format of the data depends on the string type:
265for example for an
266.Vt IA5String
267the data contains ASCII characters, for a
268.Vt BMPString
269two bytes per character in big endian format, and for a
270.Vt UTF8String
271UTF-8 characters.
272.Pp
273Similar care should be taken to ensure the data is in the correct format
274when calling
275.Fn ASN1_STRING_set .
276.Sh RETURN VALUES
277.Fn ASN1_STRING_cmp
278and
279.Fn ASN1_OCTET_STRING_cmp
280return 0 if the type, the length, and the content of
281.Fa a
282and
283.Fa b
284agree, or a non-zero value otherwise.
285In contrast to
286.Xr strcmp 3 ,
287the sign of the return value does not indicate lexicographical ordering.
288.Pp
289.Fn ASN1_STRING_data
290and
291.Fn ASN1_STRING_get0_data
292return an internal pointer to the data of
293.Fa x .
294.Pp
295.Fn ASN1_STRING_dup
296and
297.Fn ASN1_OCTET_STRING_dup
298return a pointer to a newly allocated
299.Vt ASN1_STRING
300structure or
301.Dv NULL
302if an error occurred.
303.Pp
304.Fn ASN1_STRING_length
305returns a number of bytes.
306.Pp
307.Fn ASN1_STRING_set
308and
309.Fn ASN1_OCTET_STRING_set
310return 1 on success or 0 on failure.
311.Pp
312.Fn ASN1_STRING_to_UTF8
313returns the number of bytes in the output buffer
314.Pf * Fa out ,
315or a negative number if an error occurred.
316.Pp
317.Fn ASN1_STRING_type
318returns an integer constant, for example
319.Dv V_ASN1_OCTET_STRING .
320.Pp
321In some cases of failure of
322.Fn ASN1_STRING_dup ,
323.Fn ASN1_STRING_set ,
324and
325.Fn ASN1_STRING_to_UTF8 ,
326the reason can be determined with
327.Xr ERR_get_error 3 .
328.Sh SEE ALSO
329.Xr ASN1_STRING_new 3
330.Sh HISTORY
331.Fn ASN1_STRING_cmp ,
332.Fn ASN1_STRING_dup ,
333.Fn ASN1_STRING_set ,
334and
335.Fn ASN1_OCTET_STRING_set
336first appeared in SSLeay 0.6.5.
337.Fn ASN1_OCTET_STRING_cmp ,
338.Fn ASN1_STRING_data ,
339.Fn ASN1_OCTET_STRING_dup ,
340and
341.Fn ASN1_STRING_type
342first appeared in SSLeay 0.8.0.
343.Fn ASN1_STRING_length
344first appeared in SSLeay 0.9.0.
345All these functions have been available since
346.Ox 2.4 .
347.Pp
348.Fn ASN1_STRING_length_set
349first appeared in OpenSSL 0.9.5 and has been available since
350.Ox 2.7 .
351.Pp
352.Fn ASN1_STRING_to_UTF8
353first appeared in OpenSSL 0.9.6 and has been available since
354.Ox 2.9 .
355.Pp
356.Fn ASN1_STRING_get0_data
357first appeared in OpenSSL 1.1.0 and has been available since
358.Ox 6.3 .