1.\" $OpenBSD: BN_zero.3,v 1.12 2022/11/22 19:02:07 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, 2022 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: November 22 2022 $ 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. 112It is 113.Vt unsigned long Pq = Vt uint64_t 114on 115.Dv _LP64 116platforms and 117.Vt unsigned int Pq = Vt uint32_t 118elsewhere. 119.Pp 120.Fn BN_zero_ex , 121.Fn BN_one , 122and 123.Fn BN_set_word 124set 125.Fa a 126to the values 0, 1 and 127.Fa w 128respectively. 129.Fn BN_zero 130is a deprecated version of 131.Fn BN_zero_ex 132that may attempt to allocate memory; consequently, and in contrast to 133.Fn BN_zero_ex , 134it may fail. 135.Fn BN_zero 136and 137.Fn BN_one 138are macros. 139.Pp 140.Fn BN_value_one 141returns a 142.Vt BIGNUM 143constant of value 1. 144This constant is useful for comparisons and assignments. 145.Sh RETURN VALUES 146.Fn BN_get_word 147returns the value 148.Fa a , 149or a number with all bits set if 150.Fa a 151cannot be represented as a 152.Vt BN_ULONG . 153.Pp 154.Fn BN_zero , 155.Fn BN_one , 156and 157.Fn BN_set_word 158return 1 on success, 0 otherwise. 159.Fn BN_value_one 160returns the constant. 161.Sh SEE ALSO 162.Xr BN_bn2bin 3 , 163.Xr BN_new 3 , 164.Xr BN_set_bit 3 , 165.Xr BN_set_negative 3 166.Sh HISTORY 167.Fn BN_zero , 168.Fn BN_one , 169.Fn BN_value_one , 170and 171.Fn BN_set_word 172first appeared in SSLeay 0.5.1. 173.Fn BN_get_word 174first appeared in SSLeay 0.6.0. 175These functions have been available since 176.Ox 2.4 . 177.Pp 178.Fn BN_zero_ex 179first appeared in OpenSSL 0.9.8 and has been available since 180.Ox 4.5 . 181.Sh BUGS 182Someone might change the constant. 183.Pp 184If the value of a 185.Vt BIGNUM 186is equal to a 187.Vt BN_ULONG 188with all bits set, the return value of 189.Fn BN_get_word 190collides with return value used to indicate errors. 191.Pp 192.Vt BN_ULONG 193should probably be a typedef rather than a macro. 194