10#ifndef BOTAN_GFP_CURVE_H_
11#define BOTAN_GFP_CURVE_H_
13#include <botan/bigint.h>
65 curve_mul_words(z, x.
data(), x.
size(), y, ws);
78 curve_sqr_words(z, x.
data(), x.
size(), ws);
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);
#define BOTAN_DEBUG_ASSERT(expr)
const word * data() const
void curve_mul(BigInt &z, const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
virtual size_t get_p_words() const =0
virtual BigInt invert_element(const BigInt &x, secure_vector< word > &ws) const =0
virtual ~CurveGFp_Repr()=default
virtual const BigInt & get_a() const =0
virtual void to_curve_rep(BigInt &x, secure_vector< word > &ws) const =0
virtual const BigInt & get_b() const =0
virtual bool is_one(const BigInt &x) const =0
virtual void curve_sqr_words(BigInt &z, const word x_words[], size_t x_size, secure_vector< word > &ws) const =0
virtual const BigInt & get_a_rep() const =0
void curve_sqr(BigInt &z, const BigInt &x, secure_vector< word > &ws) const
virtual const BigInt & get_b_rep() const =0
virtual void from_curve_rep(BigInt &x, secure_vector< word > &ws) const =0
virtual const BigInt & get_p() const =0
virtual size_t get_ws_size() const =0
virtual bool a_is_minus_3() const =0
virtual const BigInt & get_1_rep() const =0
virtual bool a_is_zero() const =0
virtual void curve_mul_words(BigInt &z, const word x_words[], const size_t x_size, const BigInt &y, secure_vector< word > &ws) const =0
CurveGFp(const CurveGFp &)=default
bool a_is_minus_3() const
void mul(BigInt &z, const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
void mul(BigInt &z, const word x_w[], size_t x_size, const BigInt &y, secure_vector< word > &ws) const
size_t get_ws_size() const
BigInt invert_element(const BigInt &x, secure_vector< word > &ws) const
const BigInt & get_1_rep() const
const BigInt & get_b_rep() const
bool is_one(const BigInt &x) const
void sqr(BigInt &z, const BigInt &x, secure_vector< word > &ws) const
void swap(CurveGFp &other)
const BigInt & get_a_rep() const
BigInt from_rep_to_tmp(const BigInt &x, secure_vector< word > &ws) const
void sqr(BigInt &z, const word x_w[], size_t x_size, secure_vector< word > &ws) const
const BigInt & get_a() const
void to_rep(BigInt &x, secure_vector< word > &ws) const
CurveGFp(const BigInt &p, const BigInt &a, const BigInt &b)
BigInt mul(const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
size_t get_p_words() const
CurveGFp & operator=(const CurveGFp &)=default
const BigInt & get_p() const
BigInt sqr_to_tmp(const BigInt &x, secure_vector< word > &ws) const
BigInt sqr(const BigInt &x, secure_vector< word > &ws) const
const BigInt & get_b() const
bool operator==(const CurveGFp &other) const
void from_rep(BigInt &x, secure_vector< word > &ws) const
BigInt mul_to_tmp(const BigInt &x, const BigInt &y, secure_vector< word > &ws) const
int(* final)(unsigned char *, CTX *)
#define BOTAN_UNSTABLE_API
bool operator!=(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
std::vector< T, secure_allocator< T > > secure_vector