diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/man/d2i_ASN1_BOOLEAN.3 | 126 |
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 | ||
27 | typedef 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 | ||
42 | These functions decode and encode | ||
43 | an ASN.1 value TRUE or FALSE of the type BOOLEAN. | ||
44 | In contrast to most other ASN.1 types, | ||
45 | the library does not represent the BOOLEAN type by a structure. | ||
46 | Instead, | ||
47 | .Vt ASN1_BOOLEAN | ||
48 | is simply an alias for the type | ||
49 | .Vt int . | ||
50 | .Pp | ||
51 | .Fn d2i_ASN1_BOOLEAN | ||
52 | verifies that the BER-encoded value at | ||
53 | .Pf * Fa der_in | ||
54 | is of the type BOOLEAN | ||
55 | and that the number encoded in the length octets is 1. | ||
56 | At most | ||
57 | .Fa length | ||
58 | bytes are inspected. | ||
59 | .Pp | ||
60 | Unless | ||
61 | .Fa val_out | ||
62 | is a | ||
63 | .Dv NULL | ||
64 | pointer, it copies the integer value of the single content octet to | ||
65 | .Pf * Fa val_out . | ||
66 | In case of success, | ||
67 | .Pf * Fa der_in | ||
68 | is advanced by three bytes to the byte after the content octet. | ||
69 | .Pp | ||
70 | .Fn i2d_ASN1_BOOLEAN | ||
71 | encodes an ASN.1 value of the type BOOLEAN using DER. | ||
72 | Specifically, unless | ||
73 | .Fa der_out | ||
74 | is a | ||
75 | .Dv NULL | ||
76 | pointer, it writes the identifier octet for the type BOOLEAN, | ||
77 | 0x01, the single length octet 0x01, one single content octet containing | ||
78 | .Fa val_in , | ||
79 | and no end-of-content octets to | ||
80 | .Pf * Fa der_out | ||
81 | and advances the pointer | ||
82 | .Pf * Fa der_out | ||
83 | by three bytes to the byte after the content octet. | ||
84 | Making sure that three bytes can be written to | ||
85 | .Pf * Fa der_out | ||
86 | is the responsibility of the caller. | ||
87 | .Pp | ||
88 | If | ||
89 | .Fa val_in | ||
90 | is 0, it encodes the FALSE value. | ||
91 | If | ||
92 | .Fa val_in | ||
93 | is in the range from 1 to 255 inclusive, it encodes the TRUE value. | ||
94 | .Sh RETURN VALUES | ||
95 | In case of success, | ||
96 | .Fn d2i_ASN1_BOOLEAN | ||
97 | returns the integer value of the content octet. | ||
98 | The number 0 represents the FALSE value and any number in the range | ||
99 | from 1 to 255 inclusive represents the TRUE value. | ||
100 | If the | ||
101 | .Fa length | ||
102 | argument is less than 3, if parsing fails, if the ASN.1 object at | ||
103 | .Pf * Fa der_in | ||
104 | is not of the type BOOLEAN, or if the number of content octets is not 1, | ||
105 | .Fn d2i_ASN1_BOOLEAN | ||
106 | returns \-1 to indicate the error. | ||
107 | .Pp | ||
108 | .Fn i2d_ASN1_BOOLEAN | ||
109 | always returns 3, which is the number of bytes in the BER encoding | ||
110 | of 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 | ||
117 | and | ||
118 | .Fn i2d_ASN1_BOOLEAN | ||
119 | first appeared in SSLeay 0.6.2 and have been available since | ||
120 | .Ox 2.4 . | ||
121 | .Sh CAVEATS | ||
122 | The behaviour of | ||
123 | .Fn i2d_ASN1_BOOLEAN | ||
124 | is unspecified if | ||
125 | .Fa val_in | ||
126 | is negative or larger than 255. | ||