|
Botan 3.14.1
Crypto and TLS for C&
|
#include <monty.h>
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) |
|
explicit |
Create a zero-initialized Montgomery_Int
Definition at line 230 of file monty.cpp.
Referenced by ct_cond_assign(), div2(), from_wide_int(), mul(), mul_by(), mul_by(), mul_by_word(), one(), operator+(), operator+=(), 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 247 of file monty.cpp.
References Botan::BigInt::_as_span(), BOTAN_ARG_CHECK, BOTAN_ASSERT_NOMSG, Botan::copy_mem(), mul_by(), and Botan::BigInt::signum().
| 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 270 of file monty.cpp.
References BOTAN_ARG_CHECK.
|
inline |
|
inline |
|
inline |
Definition at line 216 of file monty.h.
Referenced by Botan::make_monty_exp_avx512().
| void Botan::Montgomery_Int::ct_cond_assign | ( | bool | predicate, |
| const Montgomery_Int & | other ) |
If predicate is true assign other to this, in constant time
Definition at line 495 of file monty.cpp.
References BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, Botan::CT::conditional_assign_mem(), and Montgomery_Int().
| void Botan::Montgomery_Int::ct_cond_negate | ( | bool | predicate | ) |
If predicate is true negate this modulo p, in constant time
Definition at line 474 of file monty.cpp.
References Botan::bigint_sub3(), BOTAN_ASSERT_NOMSG, and Botan::CT::Mask< T >::expand_bool().
| Montgomery_Int & Botan::Montgomery_Int::div2 | ( | ) |
Divide by 2 modulo p
Definition at line 458 of file monty.cpp.
References Botan::bigint_cnd_add(), BOTAN_ASSERT_NOMSG, and Montgomery_Int().
|
static |
Wide reduction - input can be at most 2*bytes long
Definition at line 241 of file monty.cpp.
References Montgomery_Int(), Botan::Montgomery_Params::mul(), Botan::Montgomery_Params::R3(), and Botan::Montgomery_Params::redc().
| bool Botan::Montgomery_Int::is_zero | ( | ) | const |
Definition at line 501 of file monty.cpp.
References Botan::CT::all_zeros().
| Montgomery_Int Botan::Montgomery_Int::mul | ( | const Montgomery_Int & | other, |
| secure_vector< word > & | ws ) const |
Definition at line 326 of file monty.cpp.
References Botan::bigint_monty_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 344 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 349 of file monty.cpp.
References Botan::bigint_monty_mul(), BOTAN_ASSERT_NOMSG, and Montgomery_Int().
| Montgomery_Int & Botan::Montgomery_Int::mul_by_word | ( | word | d | ) |
Multiply by an integer d (which is not in Montgomery form)
Requires 0 <= d < 2^(WB-2), where WB is the word size in bits (so d < 2^62 with 64-bit words, or d < 2^30 with 32-bit words). Larger values throw Invalid_Argument.
This is constant time with respect to the values of this, d, and p
Definition at line 414 of file monty.cpp.
References Botan::bigint_linmul3(), Botan::bigint_monty_maybe_sub(), Botan::bigint_submul(), BOTAN_ARG_CHECK, BOTAN_ASSERT_NOMSG, Botan::CT::Mask< T >::expand(), Montgomery_Int(), and Botan::word_madd2().
|
static |
Return the value 1 in Montgomery form
Definition at line 237 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 291 of file monty.cpp.
References Botan::bigint_add3(), Botan::bigint_monty_maybe_sub(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and Montgomery_Int().
| Montgomery_Int & Botan::Montgomery_Int::operator+= | ( | const Montgomery_Int & | other | ) |
Definition at line 396 of file monty.cpp.
References BOTAN_STATE_CHECK, and Montgomery_Int().
| Montgomery_Int Botan::Montgomery_Int::operator- | ( | const Montgomery_Int & | other | ) | const |
Definition at line 312 of file monty.cpp.
References Botan::bigint_cnd_add(), Botan::bigint_sub3(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and Montgomery_Int().
| Montgomery_Int & Botan::Montgomery_Int::operator-= | ( | const Montgomery_Int & | other | ) |
Definition at line 402 of file monty.cpp.
References Botan::bigint_cnd_add(), Botan::bigint_sub2(), BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and Montgomery_Int().
|
inline |
| std::vector< uint8_t > Botan::Montgomery_Int::serialize | ( | ) | const |
Definition at line 275 of file monty.cpp.
References Botan::BigInt::serialize(), and value().
| Montgomery_Int Botan::Montgomery_Int::square | ( | secure_vector< word > & | ws | ) | const |
Definition at line 505 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 363 of file monty.cpp.
References Botan::bigint_monty_sqr(), BOTAN_ASSERT_NOMSG, 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 279 of file monty.cpp.
References Botan::BigInt::_from_words(), and Botan::bigint_monty_redc_inplace().
Referenced by Botan::DL_Group::multi_exponentiate(), Botan::power_mod(), serialize(), and Botan::sqrt_modulo_prime().