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