xref: /openbsd-src/lib/libcrypto/man/BN_zero.3 (revision c1a45aed656e7d5627c30c92421893a76f370ccb)
1.\" $OpenBSD: BN_zero.3,v 1.11 2021/12/19 16:18:34 schwarze Exp $
2.\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
9.\"
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
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Ulf Moeller <ulf@openssl.org>.
23.\" Copyright (c) 2000, 2001, 2018 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\"    notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\"    notice, this list of conditions and the following disclaimer in
35.\"    the documentation and/or other materials provided with the
36.\"    distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\"    software must display the following acknowledgment:
40.\"    "This product includes software developed by the OpenSSL Project
41.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\"    endorse or promote products derived from this software without
45.\"    prior written permission. For written permission, please contact
46.\"    openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\"    nor may "OpenSSL" appear in their names without prior written
50.\"    permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\"    acknowledgment:
54.\"    "This product includes software developed by the OpenSSL Project
55.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: December 19 2021 $
71.Dt BN_ZERO 3
72.Os
73.Sh NAME
74.Nm BN_zero_ex ,
75.Nm BN_zero ,
76.Nm BN_one ,
77.Nm BN_value_one ,
78.Nm BN_set_word ,
79.Nm BN_get_word
80.Nd BIGNUM assignment operations
81.Sh SYNOPSIS
82.In openssl/bn.h
83.Ft void
84.Fo BN_zero_ex
85.Fa "BIGNUM *a"
86.Fc
87.Ft int
88.Fo BN_zero
89.Fa "BIGNUM *a"
90.Fc
91.Ft int
92.Fo BN_one
93.Fa "BIGNUM *a"
94.Fc
95.Ft const BIGNUM *
96.Fo BN_value_one
97.Fa void
98.Fc
99.Ft int
100.Fo BN_set_word
101.Fa "BIGNUM *a"
102.Fa "BN_ULONG w"
103.Fc
104.Ft BN_ULONG
105.Fo BN_get_word
106.Fa "const BIGNUM *a"
107.Fc
108.Sh DESCRIPTION
109.Vt BN_ULONG
110is a macro that expands to an unsigned integral type optimized
111for the most efficient implementation on the local platform.
112.Pp
113.Fn BN_zero_ex ,
114.Fn BN_one ,
115and
116.Fn BN_set_word
117set
118.Fa a
119to the values 0, 1 and
120.Fa w
121respectively.
122.Fn BN_zero
123is a deprecated version of
124.Fn BN_zero_ex
125that may attempt to allocate memory; consequently, and in contrast to
126.Fn BN_zero_ex ,
127it may fail.
128.Fn BN_zero
129and
130.Fn BN_one
131are macros.
132.Pp
133.Fn BN_value_one
134returns a
135.Vt BIGNUM
136constant of value 1.
137This constant is useful for comparisons and assignments.
138.Sh RETURN VALUES
139.Fn BN_get_word
140returns the value
141.Fa a ,
142or a number with all bits set if
143.Fa a
144cannot be represented as a
145.Vt BN_ULONG .
146.Pp
147.Fn BN_zero ,
148.Fn BN_one ,
149and
150.Fn BN_set_word
151return 1 on success, 0 otherwise.
152.Fn BN_value_one
153returns the constant.
154.Sh SEE ALSO
155.Xr BN_bn2bin 3 ,
156.Xr BN_new 3 ,
157.Xr BN_set_bit 3 ,
158.Xr BN_set_negative 3
159.Sh HISTORY
160.Fn BN_zero ,
161.Fn BN_one ,
162.Fn BN_value_one ,
163and
164.Fn BN_set_word
165first appeared in SSLeay 0.5.1.
166.Fn BN_get_word
167first appeared in SSLeay 0.6.0.
168These functions have been available since
169.Ox 2.4 .
170.Pp
171.Fn BN_zero_ex
172first appeared in OpenSSL 0.9.8 and has been available since
173.Ox 4.5 .
174.Sh BUGS
175Someone might change the constant.
176.Pp
177If the value of a
178.Vt BIGNUM
179is equal to a
180.Vt BN_ULONG
181with all bits set, the return value of
182.Fn BN_get_word
183collides with return value used to indicate errors.
184.Pp
185.Vt BN_ULONG
186should probably be a typedef rather than a macro.
187