Botan 3.9.0
Crypto and TLS for C&
|
#include <monty.h>
Public Member Functions | |
void | _const_time_poison () const |
void | _const_time_unpoison () const |
const Montgomery_Params & | _params () const |
Montgomery_Int (const Montgomery_Params ¶ms) | |
Montgomery_Int (const Montgomery_Params ¶ms, const BigInt &v, bool redc_needed=true) | |
Montgomery_Int (const Montgomery_Params ¶ms, std::span< const word > words) | |
Montgomery_Int | mul (const Montgomery_Int &other, secure_vector< word > &ws) const |
Montgomery_Int & | mul_by (const Montgomery_Int &other, secure_vector< word > &ws) |
Montgomery_Int & | mul_by (std::span< const word > other, secure_vector< word > &ws) |
Montgomery_Int | operator+ (const Montgomery_Int &other) const |
Montgomery_Int | operator- (const Montgomery_Int &other) const |
const secure_vector< word > & | repr () const |
std::vector< uint8_t > | serialize () const |
Montgomery_Int | square (secure_vector< word > &ws) const |
Montgomery_Int & | square_this_n_times (secure_vector< word > &ws, size_t n) |
BigInt | value () const |
Static Public Member Functions | |
static Montgomery_Int | from_wide_int (const Montgomery_Params ¶ms, const BigInt &x) |
static Montgomery_Int | one (const Montgomery_Params ¶ms) |
|
inlineexplicit |
Create a zero-initialized Montgomery_Int
Definition at line 108 of file monty.h.
Referenced by from_wide_int(), mul(), mul_by(), mul_by(), one(), operator+(), operator-(), square(), and square_this_n_times().
Botan::Montgomery_Int::Montgomery_Int | ( | const Montgomery_Params & | params, |
const BigInt & | v, | ||
bool | redc_needed = true ) |
Create a Montgomery_Int from a BigInt
Definition at line 213 of file monty.cpp.
References Botan::BigInt::_as_span(), BOTAN_ASSERT_NOMSG, Botan::copy_mem(), and mul_by().
Botan::Montgomery_Int::Montgomery_Int | ( | const Montgomery_Params & | params, |
std::span< const word > | words ) |
Create a Montgomery_Int
The span must be exactly p_words long and encoding a value less than p already in Montgomery form
Definition at line 236 of file monty.cpp.
References BOTAN_ARG_CHECK.
|
inline |
|
inline |
|
inline |
|
static |
Wide reduction - input can be at most 2*bytes long
Definition at line 207 of file monty.cpp.
References Montgomery_Int(), Botan::Montgomery_Params::mul(), Botan::Montgomery_Params::R3(), and Botan::Montgomery_Params::redc().
Montgomery_Int Botan::Montgomery_Int::mul | ( | const Montgomery_Int & | other, |
secure_vector< word > & | ws ) const |
Definition at line 292 of file monty.cpp.
References Botan::bigint_monty_redc_inplace(), Botan::bigint_mul(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and Montgomery_Int().
Referenced by Botan::monty_multi_exp().
Montgomery_Int & Botan::Montgomery_Int::mul_by | ( | const Montgomery_Int & | other, |
secure_vector< word > & | ws ) |
Definition at line 312 of file monty.cpp.
References BOTAN_STATE_CHECK, Montgomery_Int(), and mul_by().
Referenced by Montgomery_Int(), Botan::monty_multi_exp(), and mul_by().
Montgomery_Int & Botan::Montgomery_Int::mul_by | ( | std::span< const word > | other, |
secure_vector< word > & | ws ) |
Definition at line 317 of file monty.cpp.
References Botan::bigint_monty_redc_inplace(), Botan::bigint_mul(), BOTAN_ASSERT_NOMSG, Botan::copy_mem(), and Montgomery_Int().
|
static |
Return the value 1 in Montgomery form
Definition at line 203 of file monty.cpp.
References Montgomery_Int(), and Botan::Montgomery_Params::R1().
Referenced by Botan::monty_multi_exp().
Montgomery_Int Botan::Montgomery_Int::operator+ | ( | const Montgomery_Int & | other | ) | const |
Definition at line 257 of file monty.cpp.
References Botan::bigint_add3(), Botan::bigint_monty_maybe_sub(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, Botan::carry(), and Montgomery_Int().
Montgomery_Int Botan::Montgomery_Int::operator- | ( | const Montgomery_Int & | other | ) | const |
Definition at line 278 of file monty.cpp.
References Botan::bigint_cnd_add(), Botan::bigint_sub3(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and Montgomery_Int().
|
inline |
std::vector< uint8_t > Botan::Montgomery_Int::serialize | ( | ) | const |
Definition at line 241 of file monty.cpp.
References Botan::BigInt::serialize(), and value().
Montgomery_Int Botan::Montgomery_Int::square | ( | secure_vector< word > & | ws | ) | const |
Definition at line 373 of file monty.cpp.
References Montgomery_Int(), and square_this_n_times().
Referenced by Botan::monty_multi_exp().
Montgomery_Int & Botan::Montgomery_Int::square_this_n_times | ( | secure_vector< word > & | ws, |
size_t | n ) |
Definition at line 344 of file monty.cpp.
References Botan::bigint_monty_redc_inplace(), Botan::bigint_sqr(), BOTAN_ASSERT_NOMSG, Botan::copy_mem(), and Montgomery_Int().
Referenced by Botan::monty_multi_exp(), and square().
BigInt Botan::Montgomery_Int::value | ( | ) | const |
Return the value to normal mod-p space
Definition at line 245 of file monty.cpp.
References Botan::BigInt::_from_words(), and Botan::bigint_monty_redc_inplace().
Referenced by Botan::DL_Group::multi_exponentiate(), Botan::passes_miller_rabin_test(), Botan::power_mod(), serialize(), and Botan::sqrt_modulo_prime().