Botan 3.9.0
Crypto and TLS for C&
|
#include <barrett.h>
Public Member Functions | |
BigInt | cube (const BigInt &x) const |
size_t | modulus_bits () const |
BigInt | multiply (const BigInt &x, const BigInt &y) const |
BigInt | reduce (const BigInt &x) const |
BigInt | square (const BigInt &x) const |
Static Public Member Functions | |
static Barrett_Reduction | for_public_modulus (const BigInt &m) |
static Barrett_Reduction | for_secret_modulus (const BigInt &m) |
Cube mod p
x | the value to cube |
TODO(Botan4) remove this, last few remaining callers go away in Botan4
Definition at line 66 of file barrett.h.
|
static |
Setup for reduction where the modulus itself is public
Requires that m > 0
Definition at line 33 of file barrett.cpp.
References BOTAN_ARG_CHECK, for_public_modulus(), Botan::BigInt::is_negative(), Botan::BigInt::is_zero(), Botan::BigInt::power_of_2(), and Botan::BigInt::sig_words().
Referenced by Botan::EC_Group::EC_Group(), for_public_modulus(), Botan::sqrt_modulo_prime(), and Botan::EC_Group::verify_group().
|
static |
Setup for reduction where the modulus itself is secret.
This is slower than for_public_modulus since it must avoid using variable time division.
Requires that m > 0
Definition at line 22 of file barrett.cpp.
References BOTAN_ARG_CHECK, Botan::ct_divide_pow2k(), for_secret_modulus(), Botan::BigInt::is_negative(), Botan::BigInt::is_zero(), and Botan::BigInt::sig_words().
Referenced by botan_mp_mod_mul(), for_secret_modulus(), Botan::generate_rsa_prime(), Botan::is_prime(), Botan::power_mod(), and Botan::random_prime().
|
inline |
Return length of the modulus in bits
Definition at line 71 of file barrett.h.
Referenced by Botan::EC_Point_Base_Point_Precompute::EC_Point_Base_Point_Precompute().
Multiply mod p
x | the first operand in [0..p) |
y | the second operand in [0..p) |
Definition at line 162 of file barrett.cpp.
References Botan::BigInt::_data(), Botan::bigint_mul(), BOTAN_ARG_CHECK, multiply(), and Botan::BigInt::size().
Referenced by Botan::is_lucas_probable_prime(), and multiply().
Perform modular reduction of x
The parameter must be greater than or equal to zero, and less than 2^(2*b), where b is the bitlength of the modulus.
Definition at line 194 of file barrett.cpp.
References Botan::BigInt::_as_span(), BOTAN_ARG_CHECK, Botan::BigInt::grow_to(), Botan::BigInt::is_positive(), reduce(), and Botan::BigInt::sig_words().
Referenced by Botan::is_lucas_probable_prime(), and reduce().
Square mod p
x | a value to square must be in [0..p) |
Definition at line 183 of file barrett.cpp.
References Botan::BigInt::_data(), Botan::bigint_sqr(), BOTAN_ARG_CHECK, Botan::BigInt::size(), and square().
Referenced by Botan::is_lucas_probable_prime(), Botan::passes_miller_rabin_test(), and square().