summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2021-11-15 10:41:11 +0000
committerschwarze <>2021-11-15 10:41:11 +0000
commitad83e141cc258e6ba6fb7328d224c613a3cc0510 (patch)
tree2db8975eae235499c4ae7b5113c7e7a2d0b8e558 /src/lib
parenta4c3c5d1a6bfbff90627fab679b764de5a8028cf (diff)
downloadopenbsd-ad83e141cc258e6ba6fb7328d224c613a3cc0510.tar.gz
openbsd-ad83e141cc258e6ba6fb7328d224c613a3cc0510.tar.bz2
openbsd-ad83e141cc258e6ba6fb7328d224c613a3cc0510.zip
document i2a_ASN1_STRING(3) and a2i_ASN1_STRING(3)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/ASN1_STRING_new.35
-rw-r--r--src/lib/libcrypto/man/Makefile3
-rw-r--r--src/lib/libcrypto/man/i2a_ASN1_STRING.3158
3 files changed, 163 insertions, 3 deletions
diff --git a/src/lib/libcrypto/man/ASN1_STRING_new.3 b/src/lib/libcrypto/man/ASN1_STRING_new.3
index ce2e9fdc68..54c5f7163f 100644
--- a/src/lib/libcrypto/man/ASN1_STRING_new.3
+++ b/src/lib/libcrypto/man/ASN1_STRING_new.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ASN1_STRING_new.3,v 1.18 2021/10/20 13:14:00 schwarze Exp $ 1.\" $OpenBSD: ASN1_STRING_new.3,v 1.19 2021/11/15 10:41:11 schwarze Exp $
2.\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400 2.\" OpenSSL 99d63d46 Tue Mar 24 07:52:24 2015 -0400
3.\" 3.\"
4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 4.\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\" 17.\"
18.Dd $Mdocdate: October 20 2021 $ 18.Dd $Mdocdate: November 15 2021 $
19.Dt ASN1_STRING_NEW 3 19.Dt ASN1_STRING_NEW 3
20.Os 20.Os
21.Sh NAME 21.Sh NAME
@@ -212,6 +212,7 @@ is returned and an error code can be retrieved with
212.Xr ASN1_TYPE_get 3 , 212.Xr ASN1_TYPE_get 3 ,
213.Xr d2i_ASN1_OBJECT 3 , 213.Xr d2i_ASN1_OBJECT 3 ,
214.Xr d2i_ASN1_OCTET_STRING 3 , 214.Xr d2i_ASN1_OCTET_STRING 3 ,
215.Xr i2a_ASN1_STRING 3 ,
215.Xr X509_cmp_time 3 , 216.Xr X509_cmp_time 3 ,
216.Xr X509_EXTENSION_get_object 3 , 217.Xr X509_EXTENSION_get_object 3 ,
217.Xr X509_get_ext_by_OBJ 3 , 218.Xr X509_get_ext_by_OBJ 3 ,
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index 4a22484ea3..a1e1c97b81 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.211 2021/11/11 12:06:25 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.212 2021/11/15 10:41:11 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -398,6 +398,7 @@ MAN= \
398 des_read_pw.3 \ 398 des_read_pw.3 \
399 evp.3 \ 399 evp.3 \
400 get_rfc3526_prime_8192.3 \ 400 get_rfc3526_prime_8192.3 \
401 i2a_ASN1_STRING.3 \
401 i2d_CMS_bio_stream.3 \ 402 i2d_CMS_bio_stream.3 \
402 i2d_PKCS7_bio_stream.3 \ 403 i2d_PKCS7_bio_stream.3 \
403 lh_new.3 \ 404 lh_new.3 \
diff --git a/src/lib/libcrypto/man/i2a_ASN1_STRING.3 b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
new file mode 100644
index 0000000000..fa5f071c14
--- /dev/null
+++ b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
@@ -0,0 +1,158 @@
1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.1 2021/11/15 10:41:11 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 15 2021 $
18.Dt I2A_ASN1_STRING 3
19.Os
20.Sh NAME
21.Nm i2a_ASN1_STRING ,
22.Nm a2i_ASN1_STRING
23.Nd hexadecimal dump of an ASN.1 string
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Ft int
27.Fo i2a_ASN1_STRING
28.Fa "BIO *out_bio"
29.Fa "const ASN1_STRING *a"
30.Fa "int type"
31.Fc
32.Ft int
33.Fo a2i_ASN1_STRING
34.Fa "BIO *in_bio"
35.Fa "ASN1_STRING *out_string"
36.Fa "char *buffer"
37.Fa "int size"
38.Fc
39.Sh DESCRIPTION
40The function
41.Fn i2a_ASN1_STRING
42writes a hexadecimal representation of
43.Fa a
44to
45.Fa out_bio .
46The
47.Fa type
48argument is ignored.
49.Pp
50Each byte of
51.Xr ASN1_STRING_get0_data 3
52is written as a number consisting of two upper-case hexadecimal digits.
53After each group of 70 digits, a backslash and a linefeed
54are inserted before the next digit.
55.Pp
56If the
57.Xr ASN1_STRING_length 3
58of
59.Fa a
60is 0, the single digit
61.Ql 0
62is written instead.
63If
64.Fa a
65is a
66.Dv NULL
67pointer, nothing is written.
68.Pp
69The function
70.Fn a2i_ASN1_STRING
71parses a hexadecimal representation of an ASN.1 string into
72.Fa out_string .
73Both lower-case and upper-case hexadecimal digits are accepted.
74Every pair of input digits is converted into one output byte.
75At least one pair of input digits is required.
76.Pp
77On every input line, the trailing newline character and an optional
78carrier return character character preceding it are ignored.
79The trailing newline need not be present on the last line.
80If there is a backslash character before the newline character,
81parsing is continued on the next input line.
82In particular,
83.Fn a2i_ASN1_STRING
84is able to parse the output of
85.Fn i2a_ASN1_STRING
86except when the
87.Xr ASN1_STRING_length 3
88of
89.Fa a
90was 0.
91.Pp
92Parsing fails if an input line contains an odd number of input
93digits or if memory allocation fails.
94.Pp
95This function uses the
96.Fa buffer
97provided by the caller and assumes it is at least
98.Fa size
99bytes long.
100It is unspecified what the buffer contains after the function returns.
101.Sh RETURN VALUES
102The function
103.Fn i2a_ASN1_STRING
104returns the number of bytes written or \-1 if
105.Xr BIO_write 3
106fails.
107.Pp
108The function
109.Fn a2i_ASN1_STRING
110is intended to return 1 for success or 0 for failure, but see the
111.Sx BUGS
112section for a number of traps.
113.Sh SEE ALSO
114.Xr ASN1_STRING_length 3 ,
115.Xr ASN1_STRING_new 3 ,
116.Xr ASN1_STRING_print_ex 3 ,
117.Xr i2a_ASN1_INTEGER 3 ,
118.Xr i2a_ASN1_OBJECT 3
119.Sh HISTORY
120These functions first appeared in SSLeay 0.6.5.
121The function
122.Fn a2i_ASN1_STRING
123has been part of the public API since SSLeay 0.6.5 and
124.Fn i2a_ASN1_STRING
125since SSLeay 0.8.0.
126They have been available since
127.Ox 2.4 .
128.Sh BUGS
129If the first call to
130.Xr BIO_gets 3
131does not return any data, even if that is caused by a fatal I/O error,
132if the BIO type does not support the
133.Dq gets
134operation, or if it is caused by the BIO being non-blocking,
135.Fn a2i_ASN1_STRING
136immediately succeeds and returns an empty
137.Fa out_string .
138.Pp
139If
140.Fn BIO_gets 3
141returns a partial line, for example because the given
142.Fa size
143is insufficient to contain one of the input lines
144or for reasons specific to the BIO type,
145.Fn a2i_ASN1_STRING
146may fail or silently return a truncated result.
147The caller is responsible for providing a
148.Fa buffer
149of sufficient size to contain the longest possible input line
150and for choosing a BIO of a type that only returns complete
151input lines and does not perform partial reads.
152.Pp
153The function
154.Fn a2i_ASN1_STRING
155does not support non-blocking BIOs.
156Reading is terminated as soon as
157.Xr BIO_gets 3
158returns a value less than 1.