summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2021-11-23 13:52:27 +0000
committerschwarze <>2021-11-23 13:52:27 +0000
commit78eb35459b09366e67f2b74a1cc209dbbd6bc6a8 (patch)
tree6b70fb9b079c074c39bc178d609a3170041c8f0b /src/lib
parent3af9d78c8b9e9f755a890250766ee91b89d49302 (diff)
downloadopenbsd-78eb35459b09366e67f2b74a1cc209dbbd6bc6a8.tar.gz
openbsd-78eb35459b09366e67f2b74a1cc209dbbd6bc6a8.tar.bz2
openbsd-78eb35459b09366e67f2b74a1cc209dbbd6bc6a8.zip
document a2i_ASN1_INTEGER(3),
i2a_ASN1_ENUMERATED(3), and a2i_ASN1_ENUMERATED(3)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/ASN1_INTEGER_get.341
-rw-r--r--src/lib/libcrypto/man/i2a_ASN1_STRING.3163
2 files changed, 135 insertions, 69 deletions
diff --git a/src/lib/libcrypto/man/ASN1_INTEGER_get.3 b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
index 1ed993efa6..df5a3bc821 100644
--- a/src/lib/libcrypto/man/ASN1_INTEGER_get.3
+++ b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
@@ -1,11 +1,11 @@
1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.4 2021/11/20 13:06:26 schwarze Exp $ 1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.5 2021/11/23 13:52:27 schwarze Exp $
2.\" selective merge up to: 2.\" selective merge up to:
3.\" OpenSSL man3/ASN1_INTEGER_get_int64 df75c2bf Dec 9 01:02:36 2018 +0100 3.\" OpenSSL man3/ASN1_INTEGER_get_int64 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
5.\" This file is a derived work. 5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license: 6.\" The changes are covered by the following Copyright and license:
7.\" 7.\"
8.\" Copyright (c) 2018, 2019, 2021 Ingo Schwarze <schwarze@openbsd.org> 8.\" Copyright (c) 2018, 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\" 9.\"
10.\" Permission to use, copy, modify, and distribute this software for any 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 11.\" purpose with or without fee is hereby granted, provided that the above
@@ -66,7 +66,7 @@
66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
67.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
68.\" 68.\"
69.Dd $Mdocdate: November 20 2021 $ 69.Dd $Mdocdate: November 23 2021 $
70.Dt ASN1_INTEGER_GET 3 70.Dt ASN1_INTEGER_GET 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
@@ -76,7 +76,6 @@
76.Nm ASN1_INTEGER_dup , 76.Nm ASN1_INTEGER_dup ,
77.Nm BN_to_ASN1_INTEGER , 77.Nm BN_to_ASN1_INTEGER ,
78.Nm ASN1_INTEGER_to_BN , 78.Nm ASN1_INTEGER_to_BN ,
79.Nm i2a_ASN1_INTEGER ,
80.Nm ASN1_ENUMERATED_get , 79.Nm ASN1_ENUMERATED_get ,
81.Nm ASN1_ENUMERATED_set , 80.Nm ASN1_ENUMERATED_set ,
82.Nm BN_to_ASN1_ENUMERATED , 81.Nm BN_to_ASN1_ENUMERATED ,
@@ -112,11 +111,6 @@
112.Fa "const ASN1_INTEGER *ai" 111.Fa "const ASN1_INTEGER *ai"
113.Fa "BIGNUM *bn" 112.Fa "BIGNUM *bn"
114.Fc 113.Fc
115.Ft int
116.Fo i2a_ASN1_INTEGER
117.Fa "BIO *out_bio"
118.Fa "const ASN1_INTEGER *a"
119.Fc
120.Ft long 114.Ft long
121.Fo ASN1_ENUMERATED_get 115.Fo ASN1_ENUMERATED_get
122.Fa "const ASN1_ENUMERATED *a" 116.Fa "const ASN1_ENUMERATED *a"
@@ -212,16 +206,6 @@ Otherwise, the existing object
212.Fa bn 206.Fa bn
213is used instead. 207is used instead.
214.Pp 208.Pp
215.Fn i2a_ASN1_INTEGER
216writes a hexadecimal representation of
217.Fa a
218to
219.Fa out_bio .
220The output optionally starts with a minus sign,
221followed by an even number of upper case ASCII hexadecimal digits.
222After each group of 70 digits, a backslash and a linefeed
223are inserted before the next digit.
224.Pp
225.Fn ASN1_ENUMERATED_get , 209.Fn ASN1_ENUMERATED_get ,
226.Fn ASN1_ENUMERATED_set , 210.Fn ASN1_ENUMERATED_set ,
227.Fn BN_to_ASN1_ENUMERATED , 211.Fn BN_to_ASN1_ENUMERATED ,
@@ -294,17 +278,6 @@ object of
294if an error occurs. 278if an error occurs.
295They can fail if the passed type is incorrect (due to a programming error) 279They can fail if the passed type is incorrect (due to a programming error)
296or due to memory allocation failures. 280or due to memory allocation failures.
297.Pp
298In case of success,
299.Fn i2a_ASN1_INTEGER
300returns the total number of bytes written, which is at least 2.
301It returns 0 if
302.Fa a
303is
304.Dv NULL
305or -1 if
306.Xr BIO_write 3
307fails.
308.Sh SEE ALSO 281.Sh SEE ALSO
309.Xr ASN1_INTEGER_new 3 , 282.Xr ASN1_INTEGER_new 3 ,
310.Xr ASN1_STRING_length 3 283.Xr ASN1_STRING_length 3
@@ -313,9 +286,8 @@ fails.
313first appeared in SSLeay 0.5.1. 286first appeared in SSLeay 0.5.1.
314.Fn ASN1_INTEGER_get , 287.Fn ASN1_INTEGER_get ,
315.Fn BN_to_ASN1_INTEGER , 288.Fn BN_to_ASN1_INTEGER ,
316.Fn ASN1_INTEGER_to_BN ,
317and 289and
318.Fn i2a_ASN1_INTEGER 290.Fn ASN1_INTEGER_to_BN
319first appeared in SSLeay 0.6.0. 291first appeared in SSLeay 0.6.0.
320.Fn ASN1_INTEGER_cmp 292.Fn ASN1_INTEGER_cmp
321and 293and
@@ -348,9 +320,8 @@ imply that these functions should be avoided if possible.
348.Sh BUGS 320.Sh BUGS
349.Fn ASN1_INTEGER_cmp , 321.Fn ASN1_INTEGER_cmp ,
350.Fn ASN1_INTEGER_dup , 322.Fn ASN1_INTEGER_dup ,
351.Fn ASN1_INTEGER_to_BN ,
352and 323and
353.Fn i2a_ASN1_INTEGER 324.Fn ASN1_INTEGER_to_BN
354do not check whether their arguments are really of the type 325do not check whether their arguments are really of the type
355.Dv V_ASN1_INTEGER 326.Dv V_ASN1_INTEGER
356or 327or
diff --git a/src/lib/libcrypto/man/i2a_ASN1_STRING.3 b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
index fa5f071c14..bf6266350e 100644
--- a/src/lib/libcrypto/man/i2a_ASN1_STRING.3
+++ b/src/lib/libcrypto/man/i2a_ASN1_STRING.3
@@ -1,6 +1,6 @@
1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.1 2021/11/15 10:41:11 schwarze Exp $ 1.\" $OpenBSD: i2a_ASN1_STRING.3,v 1.2 2021/11/23 13:52:27 schwarze Exp $
2.\" 2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org> 3.\" Copyright (c) 2019, 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\" 4.\"
5.\" Permission to use, copy, modify, and distribute this software for any 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 6.\" purpose with or without fee is hereby granted, provided that the above
@@ -14,12 +14,16 @@
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: November 15 2021 $ 17.Dd $Mdocdate: November 23 2021 $
18.Dt I2A_ASN1_STRING 3 18.Dt I2A_ASN1_STRING 3
19.Os 19.Os
20.Sh NAME 20.Sh NAME
21.Nm i2a_ASN1_STRING , 21.Nm i2a_ASN1_STRING ,
22.Nm a2i_ASN1_STRING 22.Nm i2a_ASN1_INTEGER ,
23.Nm i2a_ASN1_ENUMERATED ,
24.Nm a2i_ASN1_STRING ,
25.Nm a2i_ASN1_INTEGER ,
26.Nm a2i_ASN1_ENUMERATED
23.Nd hexadecimal dump of an ASN.1 string 27.Nd hexadecimal dump of an ASN.1 string
24.Sh SYNOPSIS 28.Sh SYNOPSIS
25.In openssl/asn1.h 29.In openssl/asn1.h
@@ -30,16 +34,43 @@
30.Fa "int type" 34.Fa "int type"
31.Fc 35.Fc
32.Ft int 36.Ft int
37.Fo i2a_ASN1_INTEGER
38.Fa "BIO *out_bio"
39.Fa "const ASN1_INTEGER *a"
40.Fc
41.Ft int
42.Fo i2a_ASN1_ENUMERATED
43.Fa "BIO *out_bio"
44.Fa "const i2a_ASN1_ENUMERATED *a"
45.Fc
46.Ft int
33.Fo a2i_ASN1_STRING 47.Fo a2i_ASN1_STRING
34.Fa "BIO *in_bio" 48.Fa "BIO *in_bio"
35.Fa "ASN1_STRING *out_string" 49.Fa "ASN1_STRING *out_string"
36.Fa "char *buffer" 50.Fa "char *buffer"
37.Fa "int size" 51.Fa "int size"
38.Fc 52.Fc
53.Ft int
54.Fo a2i_ASN1_INTEGER
55.Fa "BIO *in_bio"
56.Fa "ASN1_INTEGER *out_string"
57.Fa "char *buffer"
58.Fa "int size"
59.Fc
60.Ft int
61.Fo a2i_ASN1_ENUMERATED
62.Fa "BIO *in_bio"
63.Fa "ASN1_ENUMERATED *out_string"
64.Fa "char *buffer"
65.Fa "int size"
66.Fc
39.Sh DESCRIPTION 67.Sh DESCRIPTION
40The function 68The functions
41.Fn i2a_ASN1_STRING 69.Fn i2a_ASN1_STRING ,
42writes a hexadecimal representation of 70.Fn i2a_ASN1_INTEGER ,
71and
72.Fn i2a_ASN1_ENUMERATED
73write a hexadecimal representation of
43.Fa a 74.Fa a
44to 75to
45.Fa out_bio . 76.Fa out_bio .
@@ -57,33 +88,61 @@ If the
57.Xr ASN1_STRING_length 3 88.Xr ASN1_STRING_length 3
58of 89of
59.Fa a 90.Fa a
60is 0, the single digit 91is 0, instead a pair of zero digits
61.Ql 0 92.Pq Qq 00
62is written instead. 93is written by
94.Fn i2a_ASN1_INTEGER
95and
96.Fn i2a_ASN1_ENUMERATED
97and a single zero digit
98.Pq Qq 0
99by
100.Fn i2a_ASN1_STRING .
63If 101If
64.Fa a 102.Fa a
65is a 103is a
66.Dv NULL 104.Dv NULL
67pointer, nothing is written. 105pointer, nothing is written.
68.Pp 106.Pp
69The function 107If
70.Fn a2i_ASN1_STRING 108.Fa a
71parses a hexadecimal representation of an ASN.1 string into 109represents a negative integer,
110.Fn i2a_ASN1_INTEGER
111prepends a minus sign to the output.
112.Pp
113The functions
114.Fn a2i_ASN1_STRING ,
115.Fn a2i_ASN1_INTEGER ,
116and
117.Fn a2i_ASN1_ENUMERATED
118parse a hexadecimal representation of an ASN.1 string into
72.Fa out_string . 119.Fa out_string .
73Both lower-case and upper-case hexadecimal digits are accepted. 120Both lower-case and upper-case hexadecimal digits are accepted.
74Every pair of input digits is converted into one output byte. 121Every pair of input digits is converted into one output byte.
75At least one pair of input digits is required.
76.Pp 122.Pp
77On every input line, the trailing newline character and an optional 123On every input line, the trailing newline character and an optional
78carrier return character character preceding it are ignored. 124carrier return character character preceding it are ignored.
79The trailing newline need not be present on the last line. 125The trailing newline need not be present on the last line.
80If there is a backslash character before the newline character, 126If there is a backslash character before the newline character,
81parsing is continued on the next input line. 127parsing is continued on the next input line.
82In particular, 128.Pp
129At least one pair of input digits is required by
130.Fn a2i_ASN1_INTEGER
131and
132.Fn a2i_ASN1_ENUMERATED ,
133whereas
83.Fn a2i_ASN1_STRING 134.Fn a2i_ASN1_STRING
84is able to parse the output of 135converts empty input to an empty string.
136.Pp
137These functions are able to parse the output of
138.Fn i2a_ASN1_ENUMERATED .
139They can parse the output of
140.Fn i2a_ASN1_INTEGER
141unless
142.Fa a
143was negative, and they can parse the output of
85.Fn i2a_ASN1_STRING 144.Fn i2a_ASN1_STRING
86except when the 145unless the
87.Xr ASN1_STRING_length 3 146.Xr ASN1_STRING_length 3
88of 147of
89.Fa a 148.Fa a
@@ -92,39 +151,69 @@ was 0.
92Parsing fails if an input line contains an odd number of input 151Parsing fails if an input line contains an odd number of input
93digits or if memory allocation fails. 152digits or if memory allocation fails.
94.Pp 153.Pp
95This function uses the 154These functions use the
96.Fa buffer 155.Fa buffer
97provided by the caller and assumes it is at least 156provided by the caller and assume it is at least
98.Fa size 157.Fa size
99bytes long. 158bytes long.
100It is unspecified what the buffer contains after the function returns. 159It is unspecified what the buffer contains after the functions return.
101.Sh RETURN VALUES 160.Sh RETURN VALUES
102The function 161The functions
103.Fn i2a_ASN1_STRING 162.Fn i2a_ASN1_STRING ,
104returns the number of bytes written or \-1 if 163.Fn i2a_ASN1_INTEGER ,
164and
165.Fn i2a_ASN1_ENUMERATED
166return the number of bytes written or \-1 if
105.Xr BIO_write 3 167.Xr BIO_write 3
106fails. 168fails.
169In particular, they all return 0 when
170.Fa a
171is a
172.Dv NULL
173pointer.
174.Fn i2a_ASN1_STRING
175returns 1 for an empty string or an even number greater than 1
176for a string that is not empty.
177.Fn i2a_ASN1_INTEGER
178returns an even number greater than 1 for positive input
179or an odd number greater than 2 for negative input.
180.Fn i2a_ASN1_ENUMERATED
181always returns a non-negative even number when successful.
107.Pp 182.Pp
108The function 183The functions
109.Fn a2i_ASN1_STRING 184.Fn a2i_ASN1_STRING ,
110is intended to return 1 for success or 0 for failure, but see the 185.Fn a2i_ASN1_INTEGER ,
186and
187.Fn a2i_ASN1_ENUMERATED
188are intended to return 1 for success or 0 for failure, but see the
111.Sx BUGS 189.Sx BUGS
112section for a number of traps. 190section for a number of traps.
113.Sh SEE ALSO 191.Sh SEE ALSO
114.Xr ASN1_STRING_length 3 , 192.Xr ASN1_STRING_length 3 ,
115.Xr ASN1_STRING_new 3 , 193.Xr ASN1_STRING_new 3 ,
116.Xr ASN1_STRING_print_ex 3 , 194.Xr ASN1_STRING_print_ex 3 ,
117.Xr i2a_ASN1_INTEGER 3 ,
118.Xr i2a_ASN1_OBJECT 3 195.Xr i2a_ASN1_OBJECT 3
119.Sh HISTORY 196.Sh HISTORY
120These functions first appeared in SSLeay 0.6.5. 197.Fn i2a_ASN1_INTEGER
121The function 198and
199.Fn a2i_ASN1_INTEGER
200first appeared in SSLeay 0.6.0.
201.Fn i2a_ASN1_STRING
202and
203.Fn a2i_ASN1_STRING
204first appeared in SSLeay 0.6.5.
122.Fn a2i_ASN1_STRING 205.Fn a2i_ASN1_STRING
123has been part of the public API since SSLeay 0.6.5 and 206has been part of the public API since SSLeay 0.6.5 and
124.Fn i2a_ASN1_STRING 207.Fn i2a_ASN1_STRING
125since SSLeay 0.8.0. 208since SSLeay 0.8.0.
126They have been available since 209These functions have been available since
127.Ox 2.4 . 210.Ox 2.4 .
211.Pp
212.Fn i2a_ASN1_ENUMERATED
213and
214.Fn a2i_ASN1_ENUMERATED
215first appeared in OpenSSL 0.9.2 and have been available since
216.Ox 2.6 .
128.Sh BUGS 217.Sh BUGS
129If the first call to 218If the first call to
130.Xr BIO_gets 3 219.Xr BIO_gets 3
@@ -142,7 +231,10 @@ returns a partial line, for example because the given
142.Fa size 231.Fa size
143is insufficient to contain one of the input lines 232is insufficient to contain one of the input lines
144or for reasons specific to the BIO type, 233or for reasons specific to the BIO type,
145.Fn a2i_ASN1_STRING 234.Fn a2i_ASN1_STRING ,
235.Fn a2i_ASN1_INTEGER ,
236and
237.Fn a2i_ASN1_ENUMERATED
146may fail or silently return a truncated result. 238may fail or silently return a truncated result.
147The caller is responsible for providing a 239The caller is responsible for providing a
148.Fa buffer 240.Fa buffer
@@ -150,9 +242,12 @@ of sufficient size to contain the longest possible input line
150and for choosing a BIO of a type that only returns complete 242and for choosing a BIO of a type that only returns complete
151input lines and does not perform partial reads. 243input lines and does not perform partial reads.
152.Pp 244.Pp
153The function 245The functions
154.Fn a2i_ASN1_STRING 246.Fn a2i_ASN1_STRING ,
155does not support non-blocking BIOs. 247.Fn a2i_ASN1_INTEGER ,
248and
249.Fn a2i_ASN1_ENUMERATED
250do not support non-blocking BIOs.
156Reading is terminated as soon as 251Reading is terminated as soon as
157.Xr BIO_gets 3 252.Xr BIO_gets 3
158returns a value less than 1. 253returns a value less than 1.