Botan 3.5.0
Crypto and TLS for C&
|
#include <pcurves_impl.h>
Public Types | |
using | Self = IntMod<Rep> |
Public Member Functions | |
constexpr void | conditional_assign (CT::Choice cond, const Self &other) |
constexpr void | ct_poison () const |
constexpr void | ct_unpoison () const |
constexpr | IntMod () |
IntMod (const Self &other)=default | |
IntMod (Self &&other)=default | |
constexpr Self | invert () const |
constexpr CT::Choice | is_even () const |
constexpr CT::Choice | is_nonzero () const |
constexpr CT::Choice | is_one () const |
constexpr CT::Choice | is_square () const |
constexpr CT::Choice | is_zero () const |
Self | mul2 () const |
Return (*this) multiplied by 2. | |
constexpr Self | mul3 () const |
Return (*this) multiplied by 3. | |
constexpr Self | mul4 () const |
Return (*this) multiplied by 4. | |
constexpr Self | mul8 () const |
Return (*this) multiplied by 8. | |
constexpr Self | negate () const |
constexpr CT::Choice | operator!= (const Self &other) const |
constexpr Self & | operator*= (const Self &other) |
IntMod & | operator= (const Self &other)=default |
IntMod & | operator= (Self &&other)=default |
constexpr CT::Choice | operator== (const Self &other) const |
constexpr Self | pow_vartime (const std::array< W, N > &exp) const |
constexpr void | serialize_to (std::span< uint8_t, Self::BYTES > bytes) const |
constexpr Self | sqrt () const |
constexpr Self | square () const |
template<size_t L> | |
std::array< W, L > | stash_value () const |
constexpr std::array< W, Self::N > | to_words () const |
Static Public Member Functions | |
static consteval Self | constant (int8_t x) |
static constexpr std::optional< Self > | deserialize (std::span< const uint8_t > bytes) |
static Self | from_bits_with_trunc (std::span< const uint8_t > bytes) |
template<size_t L> | |
static Self | from_stash (const std::array< W, L > &stash) |
template<size_t L> | |
static constexpr Self | from_wide_bytes (std::span< const uint8_t, L > bytes) |
static constexpr std::optional< Self > | from_wide_bytes_varlen (std::span< const uint8_t > bytes) |
static constexpr Self | from_word (W x) |
template<size_t L> | |
static constexpr Self | from_words (std::array< W, L > w) |
static constexpr Self | one () |
static Self | random (RandomNumberGenerator &rng) |
static constexpr Self | zero () |
Static Public Attributes | |
static constexpr size_t | BITS = count_bits(P) |
static constexpr size_t | BYTES = (BITS + 7) / 8 |
static constexpr auto | P_MOD_4 = P[0] % 4 |
Friends | |
constexpr Self | operator* (const Self &a, const Self &b) |
constexpr Self | operator+ (const Self &a, const Self &b) |
constexpr Self | operator- (const Self &a, const Self &b) |
Definition at line 68 of file pcurves_impl.h.
using Botan::IntMod< Rep >::Self = IntMod<Rep> |
Definition at line 84 of file pcurves_impl.h.
|
inlineconstexpr |
Definition at line 87 of file pcurves_impl.h.
|
default |
|
default |
|
inlineconstexpr |
Definition at line 170 of file pcurves_impl.h.
References Botan::CT::conditional_assign_mem().
|
inlinestaticconsteval |
Definition at line 394 of file pcurves_impl.h.
References Botan::IntMod< Rep >::from_words().
|
inlineconstexpr |
Definition at line 401 of file pcurves_impl.h.
References Botan::CT::poison().
|
inlineconstexpr |
Definition at line 403 of file pcurves_impl.h.
References Botan::CT::unpoison().
|
inlinestaticconstexpr |
Definition at line 308 of file pcurves_impl.h.
References Botan::bigint_ct_is_lt(), Botan::IntMod< Rep >::BYTES, and Botan::IntMod< Rep >::from_words().
Referenced by Botan::IntMod< Rep >::random().
|
inlinestatic |
Definition at line 328 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BITS, Botan::copy_mem(), and Botan::IntMod< Rep >::from_bits_with_trunc().
Referenced by Botan::IntMod< Rep >::from_bits_with_trunc().
|
inlinestatic |
Definition at line 298 of file pcurves_impl.h.
|
inlinestaticconstexpr |
Definition at line 352 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BITS, and Botan::copy_mem().
|
inlinestaticconstexpr |
Definition at line 360 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BITS, and Botan::copy_mem().
|
inlinestaticconstexpr |
Definition at line 98 of file pcurves_impl.h.
References Botan::IntMod< Rep >::from_words().
|
inlinestaticconstexpr |
Definition at line 104 of file pcurves_impl.h.
References Botan::copy_mem().
Referenced by Botan::IntMod< Rep >::constant(), Botan::IntMod< Rep >::deserialize(), and Botan::IntMod< Rep >::from_word().
|
inlineconstexpr |
Returns the modular inverse, or 0 if no modular inverse exists.
If the modulus is prime the only value that has no modular inverse is 0.
This uses Fermat's little theorem, and so assumes that p is prime
Definition at line 238 of file pcurves_impl.h.
References Botan::IntMod< Rep >::pow_vartime().
|
inlineconstexpr |
Definition at line 121 of file pcurves_impl.h.
References Botan::CT::Choice::from_int().
|
inlineconstexpr |
|
inlineconstexpr |
Definition at line 119 of file pcurves_impl.h.
References Botan::IntMod< Rep >::one().
Referenced by Botan::IntMod< Rep >::is_square().
|
inlineconstexpr |
Definition at line 254 of file pcurves_impl.h.
References Botan::IntMod< Rep >::is_one(), Botan::IntMod< Rep >::is_zero(), and Botan::IntMod< Rep >::pow_vartime().
|
inlineconstexpr |
Definition at line 115 of file pcurves_impl.h.
References Botan::CT::all_zeros().
Referenced by Botan::IntMod< Rep >::is_nonzero(), and Botan::IntMod< Rep >::is_square().
|
inline |
Return (*this) multiplied by 2.
Definition at line 138 of file pcurves_impl.h.
References Botan::bigint_monty_maybe_sub(), Botan::carry(), and Botan::shift_left().
Referenced by Botan::IntMod< Rep >::mul3(), Botan::IntMod< Rep >::mul4(), and Botan::IntMod< Rep >::mul8().
|
inlineconstexpr |
Return (*this) multiplied by 3.
Definition at line 148 of file pcurves_impl.h.
References Botan::IntMod< Rep >::mul2().
|
inlineconstexpr |
Return (*this) multiplied by 4.
Definition at line 151 of file pcurves_impl.h.
References Botan::IntMod< Rep >::mul2().
|
inlineconstexpr |
Return (*this) multiplied by 8.
Definition at line 154 of file pcurves_impl.h.
References Botan::IntMod< Rep >::mul2().
|
inlineconstexpr |
Definition at line 181 of file pcurves_impl.h.
References Botan::CT::all_zeros(), and Botan::bigint_sub3().
|
inlinestaticconstexpr |
Definition at line 96 of file pcurves_impl.h.
Referenced by Botan::IntMod< Rep >::is_one(), and Botan::IntMod< Rep >::pow_vartime().
|
inlineconstexpr |
Definition at line 267 of file pcurves_impl.h.
References Botan::CT::is_not_equal().
|
inlineconstexpr |
Definition at line 162 of file pcurves_impl.h.
References Botan::comba_mul().
|
default |
|
default |
|
inlineconstexpr |
Definition at line 263 of file pcurves_impl.h.
References Botan::CT::is_equal().
|
inlineconstexpr |
Definition at line 190 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BITS, and Botan::IntMod< Rep >::one().
Referenced by Botan::IntMod< Rep >::invert(), Botan::IntMod< Rep >::is_square(), and Botan::IntMod< Rep >::sqrt().
|
inlinestatic |
Definition at line 369 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BITS, Botan::IntMod< Rep >::deserialize(), and Botan::RandomNumberGenerator::randomize().
|
inlineconstexpr |
Definition at line 273 of file pcurves_impl.h.
References Botan::IntMod< Rep >::BYTES, Botan::copy_mem(), and Botan::store_be().
|
inlineconstexpr |
Return the modular square root, or zero if no root exists
Current impl assumes p == 3 (mod 4)
Definition at line 245 of file pcurves_impl.h.
References Botan::IntMod< Rep >::pow_vartime(), and Botan::IntMod< Rep >::zero().
|
inlineconstexpr |
Definition at line 174 of file pcurves_impl.h.
References Botan::comba_sqr().
|
inline |
Definition at line 288 of file pcurves_impl.h.
|
inlineconstexpr |
Definition at line 271 of file pcurves_impl.h.
|
inlinestaticconstexpr |
Definition at line 156 of file pcurves_impl.h.
Definition at line 126 of file pcurves_impl.h.
Definition at line 135 of file pcurves_impl.h.
|
staticconstexpr |
Definition at line 79 of file pcurves_impl.h.
Referenced by Botan::IntMod< Rep >::from_bits_with_trunc(), Botan::IntMod< Rep >::from_wide_bytes(), Botan::IntMod< Rep >::from_wide_bytes_varlen(), Botan::IntMod< Rep >::pow_vartime(), and Botan::IntMod< Rep >::random().
|
staticconstexpr |
Definition at line 80 of file pcurves_impl.h.
Referenced by Botan::IntMod< Rep >::deserialize(), and Botan::IntMod< Rep >::serialize_to().
|
staticconstexpr |
Definition at line 82 of file pcurves_impl.h.