1.\" $OpenBSD: BN_add_word.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $ 2.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500 3.\" 4.\" This file was written by Ulf Moeller <ulf@openssl.org>. 5.\" Copyright (c) 2000, 2005 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: November 22 2022 $ 52.Dt BN_ADD_WORD 3 53.Os 54.Sh NAME 55.Nm BN_add_word , 56.Nm BN_sub_word , 57.Nm BN_mul_word , 58.Nm BN_div_word , 59.Nm BN_mod_word 60.Nd arithmetic functions on BIGNUMs with integers 61.Sh SYNOPSIS 62.In openssl/bn.h 63.Ft int 64.Fo BN_add_word 65.Fa "BIGNUM *a" 66.Fa "BN_ULONG w" 67.Fc 68.Ft int 69.Fo BN_sub_word 70.Fa "BIGNUM *a" 71.Fa "BN_ULONG w" 72.Fc 73.Ft int 74.Fo BN_mul_word 75.Fa "BIGNUM *a" 76.Fa "BN_ULONG w" 77.Fc 78.Ft BN_ULONG 79.Fo BN_div_word 80.Fa "BIGNUM *a" 81.Fa "BN_ULONG w" 82.Fc 83.Ft BN_ULONG 84.Fo BN_mod_word 85.Fa "const BIGNUM *a" 86.Fa "BN_ULONG w" 87.Fc 88.Sh DESCRIPTION 89These functions perform arithmetic operations on BIGNUMs with unsigned 90integers. 91They are much more efficient than the normal BIGNUM arithmetic 92operations. 93.Pp 94.Vt BN_ULONG 95is a macro that expands to 96.Vt unsigned long Pq = Vt uint64_t 97on 98.Dv _LP64 99platforms and 100.Vt unsigned int Pq = Vt uint32_t 101elsewhere. 102.Pp 103.Fn BN_add_word 104adds 105.Fa w 106to 107.Fa a 108.Pq Li a+=w . 109.Pp 110.Fn BN_sub_word 111subtracts 112.Fa w 113from 114.Fa a 115.Pq Li a-=w . 116.Pp 117.Fn BN_mul_word 118multiplies 119.Fa a 120and 121.Fa w 122.Pq Li a*=w . 123.Pp 124.Fn BN_div_word 125divides 126.Fa a 127by 128.Fa w 129.Pq Li a/=w 130and returns the remainder. 131.Pp 132.Fn BN_mod_word 133returns the remainder of 134.Fa a 135divided by 136.Fa w 137.Pq Li a%w . 138.Pp 139For 140.Fn BN_div_word 141and 142.Fn BN_mod_word , 143.Fa w 144must not be 0. 145.Sh RETURN VALUES 146.Fn BN_add_word , 147.Fn BN_sub_word , 148and 149.Fn BN_mul_word 150return 1 for success or 0 on error. 151The error codes can be obtained by 152.Xr ERR_get_error 3 . 153.Pp 154.Fn BN_mod_word 155and 156.Fn BN_div_word 157return 158.Fa a Ns % Ns Fa w 159on success and 160.Po Vt BN_ULONG Pc Ns -1 161if an error occurred. 162.Sh SEE ALSO 163.Xr BN_add 3 , 164.Xr BN_new 3 165.Sh HISTORY 166.Fn BN_add_word , 167.Fn BN_div_word , 168and 169.Fn BN_mod_word 170first appeared in SSLeay 0.5.1. 171.Fn BN_sub_word 172and 173.Fn BN_mul_word 174first appeared in SSLeay 0.9.0. 175All these functions have been available since 176.Ox 2.4 . 177.Pp 178Before 0.9.8a, the return value for 179.Fn BN_div_word 180and 181.Fn BN_mod_word 182in case of an error was 0. 183