|
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_NIST (size_t p_bits, 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 |
| virtual const BigInt & | get_p () const =0 |
| 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 |
Definition at line 16 of file curve_nistp.h.
| Botan::CurveGFp_NIST::CurveGFp_NIST | ( | size_t | p_bits, |
| const BigInt & | a, | ||
| const BigInt & | b | ||
| ) | [inline] |
Definition at line 19 of file curve_nistp.h.
| void Botan::CurveGFp_NIST::curve_mul | ( | BigInt & | z, |
| const BigInt & | x, | ||
| const BigInt & | y, | ||
| secure_vector< word > & | ws | ||
| ) | const [override, virtual] |
Implements Botan::CurveGFp_Repr.
Definition at line 13 of file curve_nistp.cpp.
References Botan::bigint_mul(), Botan::BigInt::clear(), Botan::BigInt::data(), 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] |
Implements Botan::CurveGFp_Repr.
Definition at line 36 of file curve_nistp.cpp.
References Botan::bigint_sqr(), Botan::BigInt::clear(), Botan::BigInt::data(), 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] |
| const BigInt& Botan::CurveGFp_NIST::get_a | ( | ) | const [inline, override, virtual] |
| const BigInt& Botan::CurveGFp_NIST::get_a_rep | ( | ) | const [inline, override, virtual] |
| const BigInt& Botan::CurveGFp_NIST::get_b | ( | ) | const [inline, override, virtual] |
| const BigInt& Botan::CurveGFp_NIST::get_b_rep | ( | ) | const [inline, override, virtual] |
| virtual const BigInt& Botan::CurveGFp_Repr::get_p | ( | ) | const [pure virtual, inherited] |
Implemented in Botan::CurveGFp_P521.
Referenced by Botan::CurveGFp_Repr::normalize().
| size_t Botan::CurveGFp_NIST::get_p_words | ( | ) | const [inline, override, virtual] |
Implements Botan::CurveGFp_Repr.
Definition at line 24 of file curve_nistp.h.
Referenced by curve_mul(), and 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);
}
}
| void Botan::CurveGFp_NIST::to_curve_rep | ( | BigInt & | x, |
| secure_vector< word > & | ws | ||
| ) | const [inline, override, virtual] |
1.7.6.1