summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2021-11-20 13:06:26 +0000
committerschwarze <>2021-11-20 13:06:26 +0000
commit8aecad67ee0cfa91c799bad6c033227065cae065 (patch)
tree41bf3d560dd40218fe8dd469701ff2d267cd6699 /src/lib
parent4b108bfbfda44e8f98286b5d9745118b1d989f59 (diff)
downloadopenbsd-8aecad67ee0cfa91c799bad6c033227065cae065.tar.gz
openbsd-8aecad67ee0cfa91c799bad6c033227065cae065.tar.bz2
openbsd-8aecad67ee0cfa91c799bad6c033227065cae065.zip
Document ASN1_INTEGER_cmp(3) and ASN1_INTEGER_dup(3).
While here, also improve the description of ASN1_INTEGER_set(3) and add a BUGS section explaining that several of these functions do not provide type safety.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/ASN1_INTEGER_get.398
1 files changed, 93 insertions, 5 deletions
diff --git a/src/lib/libcrypto/man/ASN1_INTEGER_get.3 b/src/lib/libcrypto/man/ASN1_INTEGER_get.3
index 72342ec1e0..1ed993efa6 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.3 2019/08/26 12:45:27 schwarze Exp $ 1.\" $OpenBSD: ASN1_INTEGER_get.3,v 1.4 2021/11/20 13:06:26 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 df75c2bf Dec 9 01:02:36 2018 +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 Ingo Schwarze <schwarze@openbsd.org> 8.\" Copyright (c) 2018, 2019, 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,12 +66,14 @@
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: August 26 2019 $ 69.Dd $Mdocdate: November 20 2021 $
70.Dt ASN1_INTEGER_GET 3 70.Dt ASN1_INTEGER_GET 3
71.Os 71.Os
72.Sh NAME 72.Sh NAME
73.Nm ASN1_INTEGER_get , 73.Nm ASN1_INTEGER_get ,
74.Nm ASN1_INTEGER_set , 74.Nm ASN1_INTEGER_set ,
75.Nm ASN1_INTEGER_cmp ,
76.Nm ASN1_INTEGER_dup ,
75.Nm BN_to_ASN1_INTEGER , 77.Nm BN_to_ASN1_INTEGER ,
76.Nm ASN1_INTEGER_to_BN , 78.Nm ASN1_INTEGER_to_BN ,
77.Nm i2a_ASN1_INTEGER , 79.Nm i2a_ASN1_INTEGER ,
@@ -91,6 +93,15 @@
91.Fa "ASN1_INTEGER *a" 93.Fa "ASN1_INTEGER *a"
92.Fa "long v" 94.Fa "long v"
93.Fc 95.Fc
96.Ft int
97.Fo ASN1_INTEGER_cmp
98.Fa "const ASN1_INTEGER *a1"
99.Fa "const ASN1_INTEGER *a2"
100.Fc
101.Ft ASN1_INTEGER *
102.Fo ASN1_INTEGER_dup
103.Fa "const ASN1_INTEGER *a"
104.Fc
94.Ft ASN1_INTEGER * 105.Ft ASN1_INTEGER *
95.Fo BN_to_ASN1_INTEGER 106.Fo BN_to_ASN1_INTEGER
96.Fa "const BIGNUM *bn" 107.Fa "const BIGNUM *bn"
@@ -140,11 +151,35 @@ to the
140type. 151type.
141.Pp 152.Pp
142.Fn ASN1_INTEGER_set 153.Fn ASN1_INTEGER_set
143sets the value of 154sets the type of
155.Fa a
156to
157.Dv V_ASN1_INTEGER
158or
159.Dv V_ASN1_NEG_INTEGER
160depending on the sign of
161.Fa v
162and sets the value of
144.Fa a 163.Fa a
145to 164to
146.Fa v . 165.Fa v .
147.Pp 166.Pp
167.Fn ASN1_INTEGER_cmp
168compares the signed integer numbers represented by
169.Fa a1
170and
171.Fa a2 .
172.Pp
173.Fn ASN1_INTEGER_dup
174does exactly the same as
175.Xr ASN1_STRING_dup 3
176without providing any type safety,
177except that it fails if the
178.Xr ASN1_STRING_length 3
179of
180.Fa a
181is 0.
182.Pp
148.Fn BN_to_ASN1_INTEGER 183.Fn BN_to_ASN1_INTEGER
149converts 184converts
150.Fa bn 185.Fa bn
@@ -215,6 +250,28 @@ and
215return 1 for success or 0 for failure. 250return 1 for success or 0 for failure.
216They only fail if a memory allocation error occurs. 251They only fail if a memory allocation error occurs.
217.Pp 252.Pp
253.Fn ASN1_INTEGER_cmp
254returns a value greater than, equal to, or less than 0
255if the signed integer number represented by
256.Fa a1
257is greater than, equal to, or less than
258the signed integer number represented by
259.Fa a2 ,
260respectively.
261.Pp
262.Fn ASN1_INTEGER_dup
263returns a pointer to a newly allocated
264.Vt ASN1_STRING
265structure or
266.Dv NULL
267if
268.Fa a
269is a
270.Dv NULL
271pointer, if the length of
272.Fa a
273is 0, or if memory allocation fails.
274.Pp
218.Fn BN_to_ASN1_INTEGER 275.Fn BN_to_ASN1_INTEGER
219and 276and
220.Fn BN_to_ASN1_ENUMERATED 277.Fn BN_to_ASN1_ENUMERATED
@@ -249,7 +306,8 @@ or -1 if
249.Xr BIO_write 3 306.Xr BIO_write 3
250fails. 307fails.
251.Sh SEE ALSO 308.Sh SEE ALSO
252.Xr ASN1_INTEGER_new 3 309.Xr ASN1_INTEGER_new 3 ,
310.Xr ASN1_STRING_length 3
253.Sh HISTORY 311.Sh HISTORY
254.Fn ASN1_INTEGER_set 312.Fn ASN1_INTEGER_set
255first appeared in SSLeay 0.5.1. 313first appeared in SSLeay 0.5.1.
@@ -259,6 +317,10 @@ first appeared in SSLeay 0.5.1.
259and 317and
260.Fn i2a_ASN1_INTEGER 318.Fn i2a_ASN1_INTEGER
261first appeared in SSLeay 0.6.0. 319first appeared in SSLeay 0.6.0.
320.Fn ASN1_INTEGER_cmp
321and
322.Fn ASN1_INTEGER_dup
323first appeared in SSLeay 0.6.5.
262These functions have been available since 324These functions have been available since
263.Ox 2.3 . 325.Ox 2.3 .
264.Pp 326.Pp
@@ -283,3 +345,29 @@ The ambiguous return values of
283and 345and
284.Fn ASN1_ENUMERATED_get 346.Fn ASN1_ENUMERATED_get
285imply that these functions should be avoided if possible. 347imply that these functions should be avoided if possible.
348.Sh BUGS
349.Fn ASN1_INTEGER_cmp ,
350.Fn ASN1_INTEGER_dup ,
351.Fn ASN1_INTEGER_to_BN ,
352and
353.Fn i2a_ASN1_INTEGER
354do not check whether their arguments are really of the type
355.Dv V_ASN1_INTEGER
356or
357.Dv V_ASN1_NEG_INTEGER .
358They may report success even if their arguments are of a wrong type.
359Consequently, even in case of success, the return value of
360.Fn ASN1_INTEGER_dup
361is not guaranteed to be of the type
362.Dv V_ASN1_INTEGER
363or
364.Dv V_ASN1_NEG_INTEGER
365either.
366.Pp
367Similarly,
368.Fn ASN1_ENUMERATED_to_BN
369does not check whether its argument is really of the type
370.Dv V_ASN1_ENUMERATED
371or
372.Dv V_ASN1_NEG_ENUMERATED
373and may report success even if the argument is of a wrong type.