|
Botan 3.14.1
Crypto and TLS for C&
|
#include <barrett.h>
Public Member Functions | |
| BigInt | cube (const BigInt &x) const |
| size_t | modulus_bits () const |
| const BigInt & | mu () 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
Currently implemented identically to for_secret_modulus; the distinction documents the caller's intent
Requires that m > 0
Definition at line 33 of file barrett.cpp.
References for_public_modulus(), and for_secret_modulus().
Referenced by Botan::EC_Group::EC_Group(), Botan::EC_Group_Data::EC_Group_Data(), for_public_modulus(), Botan::EC_Group::register_custom_group(), Botan::sqrt_modulo_prime(), and Botan::EC_Group::verify_group().
|
static |
Setup for reduction where the modulus itself is secret.
Requires that m > 0
Definition at line 23 of file barrett.cpp.
References BOTAN_ARG_CHECK, Botan::ct_divide_pow2k(), for_secret_modulus(), Botan::BigInt::sig_words(), and Botan::BigInt::signum().
Referenced by botan_mp_mod_mul(), for_public_modulus(), for_secret_modulus(), and Botan::power_mod().
|
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().
|
inline |
Multiply mod p
| x | the first operand in [0..p) |
| y | the second operand in [0..p) |
Definition at line 146 of file barrett.cpp.
References Botan::BigInt::_data(), Botan::bigint_mul(), BOTAN_ARG_CHECK, multiply(), and Botan::BigInt::size().
Referenced by 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 178 of file barrett.cpp.
References Botan::BigInt::_as_span(), BOTAN_ARG_CHECK, Botan::BigInt::grow_to(), reduce(), Botan::BigInt::sig_words(), and Botan::BigInt::signum().
Referenced by reduce().
Square mod p
| x | a value to square must be in [0..p) |
Definition at line 167 of file barrett.cpp.
References Botan::BigInt::_data(), Botan::bigint_sqr(), BOTAN_ARG_CHECK, Botan::BigInt::size(), and square().
Referenced by square().