#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);
_B_N___s_u_b_(_) subtracts _b from _a and places the result in _r ("r=a-b").
_B_N___m_u_l_(_) multiplies _a and _b and places the result in _r ("r=a*b"). _r may be the same BBIIGGNNUUMM as _a or _b. For multiplication by powers of 2, use _B_N___l_s_h_i_f_t(3).
_B_N___s_q_r_(_) takes the square of _a and places the result in _r ("r=a^2"). _r and _a may be the same BBIIGGNNUUMM. This function is faster than BN_mul(r,a,a).
_B_N___d_i_v_(_) divides _a by _d and places the result in _d_v and the remainder in _r_e_m ("dv=a/d, rem=a%d"). Either of _d_v and _r_e_m may be NNUULLLL, in which case the respective value is not returned. The result is rounded towards zero; thus if _a is negative, the remainder will be zero or negative. For division by powers of 2, use _B_N___r_s_h_i_f_t(3).
_B_N___m_o_d_(_) corresponds to _B_N___d_i_v_(_) with _d_v set to NNUULLLL.
_B_N___n_n_m_o_d_(_) reduces _a modulo _m and places the non-negative remainder in _r.
_B_N___m_o_d___a_d_d_(_) adds _a to _b modulo _m and places the non-negative result in _r.
_B_N___m_o_d___s_u_b_(_) subtracts _b from _a modulo _m and places the non-negative result in _r.
_B_N___m_o_d___m_u_l_(_) multiplies _a by _b and finds the non-negative remainder respective to modulus _m ("r=(a*b) mod m"). _r may be the same BBIIGGNNUUMM as _a or _b. For more efficient algorithms for repeated computations using the same modulus, see _B_N___m_o_d___m_u_l___m_o_n_t_g_o_m_e_r_y(3) and _B_N___m_o_d___m_u_l___r_e_c_i_p_r_o_c_a_l(3).
_B_N___m_o_d___s_q_r_(_) takes the square of _a modulo mm and places the result in _r.
_B_N___e_x_p_(_) raises _a to the _p-th power and places the result in _r ("r=a^p"). This function is faster than repeated applications of _B_N___m_u_l_(_).
_B_N___m_o_d___e_x_p_(_) computes _a to the _p-th power modulo _m ("r=a^p % m"). This function uses less time and space than _B_N___e_x_p_(_).
_B_N___g_c_d_(_) computes the greatest common divisor of _a and _b and places the result in _r. _r may be the same BBIIGGNNUUMM as _a or _b.
For all functions, _c_t_x is a previously allocated BBNN__CCTTXX used for temporary variables; see _B_N___C_T_X___n_e_w(3).
Unless noted otherwise, the result BBIIGGNNUUMM must be different from the arguments.