1.\" $OpenBSD: BN_zero.3,v 1.13 2023/04/30 19:23:54 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 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: April 30 2023 $ 71.Dt BN_ZERO 3 72.Os 73.Sh NAME 74.Nm BN_zero , 75.Nm BN_one , 76.Nm BN_value_one , 77.Nm BN_set_word , 78.Nm BN_get_word 79.Nd BIGNUM assignment operations 80.Sh SYNOPSIS 81.In openssl/bn.h 82.Ft int 83.Fo BN_zero 84.Fa "BIGNUM *a" 85.Fc 86.Ft int 87.Fo BN_one 88.Fa "BIGNUM *a" 89.Fc 90.Ft const BIGNUM * 91.Fo BN_value_one 92.Fa void 93.Fc 94.Ft int 95.Fo BN_set_word 96.Fa "BIGNUM *a" 97.Fa "BN_ULONG w" 98.Fc 99.Ft BN_ULONG 100.Fo BN_get_word 101.Fa "const BIGNUM *a" 102.Fc 103.Sh DESCRIPTION 104.Vt BN_ULONG 105is a macro that expands to an unsigned integral type optimized 106for the most efficient implementation on the local platform. 107It is 108.Vt unsigned long Pq = Vt uint64_t 109on 110.Dv _LP64 111platforms and 112.Vt unsigned int Pq = Vt uint32_t 113elsewhere. 114.Pp 115.Fn BN_zero , 116.Fn BN_one , 117and 118.Fn BN_set_word 119set 120.Fa a 121to the values 0, 1 and 122.Fa w 123respectively. 124.Pp 125.Fn BN_value_one 126returns a 127.Vt BIGNUM 128constant of value 1. 129This constant is useful for comparisons and assignments. 130.Sh RETURN VALUES 131.Fn BN_get_word 132returns the value 133.Fa a , 134or a number with all bits set if 135.Fa a 136cannot be represented as a 137.Vt BN_ULONG . 138.Pp 139.Fn BN_zero , 140.Fn BN_one , 141and 142.Fn BN_set_word 143return 1 on success, 0 otherwise. 144.Fn BN_value_one 145returns the constant. 146.Sh SEE ALSO 147.Xr BN_bn2bin 3 , 148.Xr BN_new 3 , 149.Xr BN_set_bit 3 , 150.Xr BN_set_negative 3 151.Sh HISTORY 152.Fn BN_zero , 153.Fn BN_one , 154.Fn BN_value_one , 155and 156.Fn BN_set_word 157first appeared in SSLeay 0.5.1. 158.Fn BN_get_word 159first appeared in SSLeay 0.6.0. 160These functions have been available since 161.Ox 2.4 . 162.Sh BUGS 163Someone might change the constant. 164.Pp 165If the value of a 166.Vt BIGNUM 167is equal to a 168.Vt BN_ULONG 169with all bits set, the return value of 170.Fn BN_get_word 171collides with return value used to indicate errors. 172.Pp 173.Vt BN_ULONG 174should probably be a typedef rather than a macro. 175