10 #ifndef BOTAN_GFP_CURVE_H_
11 #define BOTAN_GFP_CURVE_H_
13 #include <botan/bigint.h>
26 virtual const BigInt& get_p()
const = 0;
27 virtual const BigInt& get_a()
const = 0;
28 virtual const BigInt& get_b()
const = 0;
30 virtual size_t get_p_words()
const = 0;
32 virtual size_t get_ws_size()
const = 0;
34 virtual bool is_one(
const BigInt& x)
const = 0;
36 virtual bool a_is_zero()
const = 0;
38 virtual bool a_is_minus_3()
const = 0;
43 virtual const BigInt& get_a_rep()
const = 0;
48 virtual const BigInt& get_b_rep()
const = 0;
53 virtual const BigInt& get_1_rep()
const = 0;
65 curve_mul_words(z, x.
data(), x.
size(), y, ws);
68 virtual void curve_mul_words(
BigInt& z,
78 curve_sqr_words(z, x.
data(), x.
size(), ws);
81 virtual void curve_sqr_words(
BigInt& z,
112 m_repr(choose_repr(p, a, b))
153 return m_repr->invert_element(x, ws);
158 m_repr->to_curve_rep(x, ws);
163 m_repr->from_curve_rep(x, ws);
169 m_repr->from_curve_rep(xt, ws);
177 m_repr->curve_mul(z, x, y, ws);
183 m_repr->curve_mul_words(z, x_w, x_size, y, ws);
188 m_repr->curve_sqr(z, x, ws);
193 m_repr->curve_sqr_words(z, x_w, x_size, ws);
198 return mul_to_tmp(x, y, ws);
203 return sqr_to_tmp(x, ws);
209 m_repr->curve_mul(z, x, y, ws);
216 m_repr->curve_sqr(z, x, ws);
222 std::swap(m_repr, other.m_repr);
232 if(m_repr.get() == other.m_repr.get())
235 return (get_p() == other.
get_p()) &&
236 (get_a() == other.
get_a()) &&
237 (get_b() == other.
get_b());
241 static std::shared_ptr<CurveGFp_Repr>
244 std::shared_ptr<CurveGFp_Repr> m_repr;
249 return !(lhs == rhs);
const BigInt & get_a() const
void sqr(BigInt &z, const BigInt &x, secure_vector< word > &ws) const
#define BOTAN_UNSTABLE_API
bool operator!=(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
void curve_sqr(BigInt &z, const BigInt &x, secure_vector< word > &ws) const
bool is_one(const BigInt &x) const
BigInt mul(const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
CurveGFp(const BigInt &p, const BigInt &a, const BigInt &b)
const BigInt & get_b() const
void sqr(BigInt &z, const word x_w[], size_t x_size, secure_vector< word > &ws) const
int(* final)(unsigned char *, CTX *)
bool operator==(const CurveGFp &other) const
const BigInt & get_a_rep() const
size_t get_p_words() const
BigInt sqr(const BigInt &x, secure_vector< word > &ws) const
size_t get_ws_size() const
BigInt invert_element(const BigInt &x, secure_vector< word > &ws) const
std::vector< T, secure_allocator< T >> secure_vector
void curve_mul(BigInt &z, const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
void to_rep(BigInt &x, secure_vector< word > &ws) const
#define BOTAN_DEBUG_ASSERT(expr)
void from_rep(BigInt &x, secure_vector< word > &ws) const
bool a_is_minus_3() const
const word * data() const
const BigInt & get_b_rep() const
void swap(CurveGFp &other)
const BigInt & get_p() const
BigInt from_rep_to_tmp(const BigInt &x, secure_vector< word > &ws) const
BigInt mul_to_tmp(const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
const BigInt & get_1_rep() const
void mul(BigInt &z, const word x_w[], size_t x_size, const BigInt &y, secure_vector< word > &ws) const
void mul(BigInt &z, const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
BigInt sqr_to_tmp(const BigInt &x, secure_vector< word > &ws) const