=pod =head1 NAME BN_add, BN_sub, BN_mul, BN_sqr, BN_div, BN_mod, BN_nnmod, BN_mod_add, BN_mod_sub, BN_mod_mul, BN_mod_sqr, BN_exp, BN_mod_exp, BN_gcd - arithmetic operations on BIGNUMs =head1 SYNOPSIS #include int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx); int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, BN_CTX *ctx); int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_add(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_sqr(BIGNUM *r, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); =head1 DESCRIPTION BN_add() adds I and I and places the result in I (C). I may be the same B as I or I. BN_sub() subtracts I from I and places the result in I (C). I may be the same B as I or I. BN_mul() multiplies I and I and places the result in I (C). I may be the same B as I or I. For multiplication by powers of 2, use L. BN_sqr() takes the square of I and places the result in I (C). I and I may be the same B. This function is faster than BN_mul(r,a,a). BN_div() divides I by I and places the result in I and the remainder in I (C). Either of I and I may be B, in which case the respective value is not returned. The result is rounded towards zero; thus if I is negative, the remainder will be zero or negative. For division by powers of 2, use BN_rshift(3). BN_mod() corresponds to BN_div() with I set to B. BN_nnmod() reduces I modulo I and places the non-negative remainder in I. BN_mod_add() adds I to I modulo I and places the non-negative result in I. BN_mod_sub() subtracts I from I modulo I and places the non-negative result in I. BN_mod_mul() multiplies I by I and finds the non-negative remainder respective to modulus I (C). I may be the same B as I or I. For more efficient algorithms for repeated computations using the same modulus, see L and L. BN_mod_sqr() takes the square of I modulo B and places the result in I. BN_exp() raises I to the I

-th power and places the result in I (C). This function is faster than repeated applications of BN_mul(). BN_mod_exp() computes I to the I

-th power modulo I (C). This function uses less time and space than BN_exp(). Do not call this function when B is even and any of the parameters have the B flag set. BN_gcd() computes the greatest common divisor of I and I and places the result in I. I may be the same B as I or I. For all functions, I is a previously allocated B used for temporary variables; see L. Unless noted otherwise, the result B must be different from the arguments. =head1 RETURN VALUES For all functions, 1 is returned for success, 0 on error. The return value should always be checked (e.g., C). The error codes can be obtained by L. =head1 SEE ALSO L, L, L, L =head1 COPYRIGHT Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at L. =cut