summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3 b/src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3
new file mode 100644
index 0000000000..ecd768f081
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3
@@ -0,0 +1,126 @@
1.\" $OpenBSD: d2i_ASN1_BOOLEAN.3,v 1.1 2021/11/21 15:11:01 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 21 2021 $
18.Dt D2I_ASN1_BOOLEAN 3
19.Os
20.Sh NAME
21.Nm d2i_ASN1_BOOLEAN ,
22.Nm i2d_ASN1_BOOLEAN
23.Nd decode and encode an ASN.1 BOOLEAN value
24.Sh SYNOPSIS
25.In openssl/asn1.h
26.Bd -unfilled
27typedef int ASN1_BOOLEAN;
28.Ed
29.Pp
30.Ft int
31.Fo d2i_ASN1_BOOLEAN
32.Fa "int *val_out"
33.Fa "const unsigned char **der_in"
34.Fa "long length"
35.Fc
36.Ft int
37.Fo i2d_ASN1_BOOLEAN
38.Fa "int val_in"
39.Fa "unsigned char **der_out"
40.Fc
41.Sh DESCRIPTION
42These functions decode and encode
43an ASN.1 value TRUE or FALSE of the type BOOLEAN.
44In contrast to most other ASN.1 types,
45the library does not represent the BOOLEAN type by a structure.
46Instead,
47.Vt ASN1_BOOLEAN
48is simply an alias for the type
49.Vt int .
50.Pp
51.Fn d2i_ASN1_BOOLEAN
52verifies that the BER-encoded value at
53.Pf * Fa der_in
54is of the type BOOLEAN
55and that the number encoded in the length octets is 1.
56At most
57.Fa length
58bytes are inspected.
59.Pp
60Unless
61.Fa val_out
62is a
63.Dv NULL
64pointer, it copies the integer value of the single content octet to
65.Pf * Fa val_out .
66In case of success,
67.Pf * Fa der_in
68is advanced by three bytes to the byte after the content octet.
69.Pp
70.Fn i2d_ASN1_BOOLEAN
71encodes an ASN.1 value of the type BOOLEAN using DER.
72Specifically, unless
73.Fa der_out
74is a
75.Dv NULL
76pointer, it writes the identifier octet for the type BOOLEAN,
770x01, the single length octet 0x01, one single content octet containing
78.Fa val_in ,
79and no end-of-content octets to
80.Pf * Fa der_out
81and advances the pointer
82.Pf * Fa der_out
83by three bytes to the byte after the content octet.
84Making sure that three bytes can be written to
85.Pf * Fa der_out
86is the responsibility of the caller.
87.Pp
88If
89.Fa val_in
90is 0, it encodes the FALSE value.
91If
92.Fa val_in
93is in the range from 1 to 255 inclusive, it encodes the TRUE value.
94.Sh RETURN VALUES
95In case of success,
96.Fn d2i_ASN1_BOOLEAN
97returns the integer value of the content octet.
98The number 0 represents the FALSE value and any number in the range
99from 1 to 255 inclusive represents the TRUE value.
100If the
101.Fa length
102argument is less than 3, if parsing fails, if the ASN.1 object at
103.Pf * Fa der_in
104is not of the type BOOLEAN, or if the number of content octets is not 1,
105.Fn d2i_ASN1_BOOLEAN
106returns \-1 to indicate the error.
107.Pp
108.Fn i2d_ASN1_BOOLEAN
109always returns 3, which is the number of bytes in the BER encoding
110of an ASN.1 BOOLEAN value.
111.Sh SEE ALSO
112.Xr ASN1_get_object 3 ,
113.Xr ASN1_item_d2i 3 ,
114.Xr ASN1_put_object 3
115.Sh HISTORY
116.Fn d2i_ASN1_BOOLEAN
117and
118.Fn i2d_ASN1_BOOLEAN
119first appeared in SSLeay 0.6.2 and have been available since
120.Ox 2.4 .
121.Sh CAVEATS
122The behaviour of
123.Fn i2d_ASN1_BOOLEAN
124is unspecified if
125.Fa val_in
126is negative or larger than 255.