1 .\" $OpenBSD: BN_add.3,v 1.13 2018/04/29 15:58:21 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Ulf Moeller <ulf@openssl.org>
5 .\" and Bodo Moeller <bodo@openssl.org>.
6 .\" Copyright (c) 2000, 2001, 2015 The OpenSSL Project. All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: April 29 2018 $
69 .\" The following are public, but intentionally undocumented for now:
70 .\" .Nm BN_mod_exp_mont_consttime ,
71 .\" .Nm BN_mod_exp_mont ,
72 .\" .Nm BN_mod_exp_mont_word ,
73 .\" .Nm BN_mod_exp_recp ,
74 .\" .Nm BN_mod_exp_simple ,
75 .\" Maybe they should be deleted from <openssl/bn.h>.
77 .Nd arithmetic operations on BIGNUMs
109 .Fa "const BIGNUM *a"
110 .Fa "const BIGNUM *d"
116 .Fa "const BIGNUM *a"
117 .Fa "const BIGNUM *m"
123 .Fa "const BIGNUM *a"
124 .Fa "const BIGNUM *m"
132 .Fa "const BIGNUM *m"
140 .Fa "const BIGNUM *m"
148 .Fa "const BIGNUM *m"
155 .Fa "const BIGNUM *m"
169 .Fa "const BIGNUM *p"
170 .Fa "const BIGNUM *m"
186 and places the result in
202 and places the result in
218 and places the result in
228 For multiplication by powers of 2, use
234 and places the result in
242 This function is faster than
250 and places the result in
254 .Pq Li dv=a/d , rem=a%d .
261 it operates in constant time.
268 in which case the respective value is not returned.
269 The result is rounded towards zero; thus if
271 is negative, the remainder will be zero or negative.
272 For division by powers of 2, use
282 It is implemented as a macro.
289 and places the non-negative remainder in
299 and places the non-negative result in
309 and places the non-negative result in
317 and finds the non-negative remainder respective to modulus
327 For more efficient algorithms for repeated computations using the same
329 .Xr BN_mod_mul_montgomery 3
331 .Xr BN_mod_mul_reciprocal 3 .
338 and places the result in
346 power and places the result in
349 This function is faster than repeated applications of
364 it operates in constant time.
365 This function uses less time and space than
369 computes the greatest common divisor of
373 and places the result in
385 is a previously allocated
387 used for temporary variables; see
390 Unless noted otherwise, the result
392 must be different from the arguments.
394 For all functions, 1 is returned for success, 0 on error.
395 The return value should always be checked, for example:
397 .Dl if (!BN_add(r,a,b)) goto err;
399 The error codes can be obtained by
400 .Xr ERR_get_error 3 .
407 .Xr BN_set_negative 3
419 first appeared in SSLeay 0.5.1.
421 first appeared in SSLeay 0.9.0.
422 All these functions have been available since
429 was added in SSLeay 0.9.1 and
437 first appeared in OpenSSL 0.9.7 and have been available since
447 neither fails nor operates in constant time, potentially allowing
448 timing side-channel attacks.
458 does not operate in constant time, potentially allowing
459 timing side-channel attacks.
466 fails instead of operating in constant time.