Botan
1.11.15
|
#include <curve_nistp.h>
Public Member Functions | |
void | curve_mul (BigInt &z, const BigInt &x, const BigInt &y, secure_vector< word > &ws) const override |
void | curve_sqr (BigInt &z, const BigInt &x, secure_vector< word > &ws) const override |
CurveGFp_P521 (const BigInt &a, const BigInt &b) | |
void | from_curve_rep (BigInt &x, secure_vector< word > &ws) const override |
const BigInt & | get_a () const override |
const BigInt & | get_a_rep () const override |
const BigInt & | get_b () const override |
const BigInt & | get_b_rep () const override |
const BigInt & | get_p () const override |
size_t | get_p_words () const override |
virtual void | normalize (BigInt &x, secure_vector< word > &ws, size_t bound) const |
void | to_curve_rep (BigInt &x, secure_vector< word > &ws) const override |
Static Public Member Functions | |
static const BigInt & | prime () |
The NIST P-521 curve
Definition at line 135 of file curve_nistp.h.
Botan::CurveGFp_P521::CurveGFp_P521 | ( | const BigInt & | a, |
const BigInt & | b | ||
) | [inline] |
Definition at line 138 of file curve_nistp.h.
: CurveGFp_NIST(521, a, b) {}
void Botan::CurveGFp_NIST::curve_mul | ( | BigInt & | z, |
const BigInt & | x, | ||
const BigInt & | y, | ||
secure_vector< word > & | ws | ||
) | const [override, virtual, inherited] |
Implements Botan::CurveGFp_Repr.
Definition at line 13 of file curve_nistp.cpp.
References Botan::bigint_mul(), Botan::BigInt::clear(), Botan::BigInt::data(), Botan::CurveGFp_NIST::get_p_words(), Botan::BigInt::grow_to(), Botan::BigInt::is_zero(), Botan::BigInt::mutable_data(), Botan::BigInt::sig_words(), and Botan::BigInt::size().
{ if(x.is_zero() || y.is_zero()) { z = 0; return; } const size_t p_words = get_p_words(); const size_t output_size = 2*p_words + 1; ws.resize(2*(p_words+2)); z.grow_to(output_size); z.clear(); bigint_mul(z.mutable_data(), output_size, &ws[0], x.data(), x.size(), x.sig_words(), y.data(), y.size(), y.sig_words()); this->redc(z, ws); }
void Botan::CurveGFp_NIST::curve_sqr | ( | BigInt & | z, |
const BigInt & | x, | ||
secure_vector< word > & | ws | ||
) | const [override, virtual, inherited] |
Implements Botan::CurveGFp_Repr.
Definition at line 36 of file curve_nistp.cpp.
References Botan::bigint_sqr(), Botan::BigInt::clear(), Botan::BigInt::data(), Botan::CurveGFp_NIST::get_p_words(), Botan::BigInt::grow_to(), Botan::BigInt::is_zero(), Botan::BigInt::mutable_data(), Botan::BigInt::sig_words(), and Botan::BigInt::size().
{ if(x.is_zero()) { z = 0; return; } const size_t p_words = get_p_words(); const size_t output_size = 2*p_words + 1; ws.resize(2*(p_words+2)); z.grow_to(output_size); z.clear(); bigint_sqr(z.mutable_data(), output_size, &ws[0], x.data(), x.size(), x.sig_words()); this->redc(z, ws); }
void Botan::CurveGFp_NIST::from_curve_rep | ( | BigInt & | x, |
secure_vector< word > & | ws | ||
) | const [inline, override, virtual, inherited] |
const BigInt& Botan::CurveGFp_NIST::get_a | ( | ) | const [inline, override, virtual, inherited] |
const BigInt& Botan::CurveGFp_NIST::get_a_rep | ( | ) | const [inline, override, virtual, inherited] |
const BigInt& Botan::CurveGFp_NIST::get_b | ( | ) | const [inline, override, virtual, inherited] |
const BigInt& Botan::CurveGFp_NIST::get_b_rep | ( | ) | const [inline, override, virtual, inherited] |
const BigInt& Botan::CurveGFp_P521::get_p | ( | ) | const [inline, override, virtual] |
Implements Botan::CurveGFp_Repr.
Definition at line 142 of file curve_nistp.h.
References prime().
{ return CurveGFp_P521::prime(); }
size_t Botan::CurveGFp_NIST::get_p_words | ( | ) | const [inline, override, virtual, inherited] |
Implements Botan::CurveGFp_Repr.
Definition at line 24 of file curve_nistp.h.
Referenced by Botan::CurveGFp_NIST::curve_mul(), and Botan::CurveGFp_NIST::curve_sqr().
{ return m_p_words; }
void Botan::CurveGFp_Repr::normalize | ( | BigInt & | x, |
secure_vector< word > & | ws, | ||
size_t | bound | ||
) | const [virtual, inherited] |
Definition at line 121 of file curve_gfp.cpp.
References Botan::BigInt::data(), Botan::CurveGFp_Repr::get_p(), Botan::CurveGFp_Repr::get_p_words(), Botan::BigInt::grow_to(), Botan::BigInt::is_negative(), Botan::BigInt::swap_reg(), and Botan::word_sub().
{ const BigInt& p = get_p(); const word* prime = p.data(); const size_t p_words = get_p_words(); while(x.is_negative()) x += p; x.grow_to(p_words + 1); if(ws.size() < p_words + 1) ws.resize(p_words + 1); for(size_t i = 0; bound == 0 || i < bound; ++i) { const word* xd = x.data(); word borrow = 0; for(size_t i = 0; i != p_words; ++i) ws[i] = word_sub(xd[i], prime[i], &borrow); ws[p_words] = word_sub(xd[p_words], 0, &borrow); if(borrow) break; x.swap_reg(ws); } }
const BigInt & Botan::CurveGFp_P521::prime | ( | ) | [static] |
Definition at line 60 of file curve_nistp.cpp.
Referenced by get_p().
{ static const BigInt p521("0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); return p521; }
void Botan::CurveGFp_NIST::to_curve_rep | ( | BigInt & | x, |
secure_vector< word > & | ws | ||
) | const [inline, override, virtual, inherited] |