Botan  1.11.15
Public Member Functions
Botan::CurveGFp_NIST Class Reference

#include <curve_nistp.h>

Inheritance diagram for Botan::CurveGFp_NIST:
Botan::CurveGFp_Repr Botan::CurveGFp_P521

List of all members.

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 BigIntget_a () const override
const BigIntget_a_rep () const override
const BigIntget_b () const override
const BigIntget_b_rep () const override
virtual const BigIntget_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

Detailed Description

Definition at line 16 of file curve_nistp.h.


Constructor & Destructor Documentation

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.

                                                                     :
         m_a(a), m_b(b), m_p_words((p_bits + BOTAN_MP_WORD_BITS - 1) / BOTAN_MP_WORD_BITS)
         {
         }

Member Function Documentation

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]

Implements Botan::CurveGFp_Repr.

Definition at line 37 of file curve_nistp.h.

         { redc(x, ws); }
const BigInt& Botan::CurveGFp_NIST::get_a ( ) const [inline, override, virtual]

Implements Botan::CurveGFp_Repr.

Definition at line 26 of file curve_nistp.h.

{ return m_a; }
const BigInt& Botan::CurveGFp_NIST::get_a_rep ( ) const [inline, override, virtual]

Implements Botan::CurveGFp_Repr.

Definition at line 30 of file curve_nistp.h.

{ return m_a; }
const BigInt& Botan::CurveGFp_NIST::get_b ( ) const [inline, override, virtual]

Implements Botan::CurveGFp_Repr.

Definition at line 28 of file curve_nistp.h.

{ return m_b; }
const BigInt& Botan::CurveGFp_NIST::get_b_rep ( ) const [inline, override, virtual]

Implements Botan::CurveGFp_Repr.

Definition at line 32 of file curve_nistp.h.

{ return m_b; }
virtual const BigInt& Botan::CurveGFp_Repr::get_p ( ) const [pure virtual, inherited]
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]

Implements Botan::CurveGFp_Repr.

Definition at line 34 of file curve_nistp.h.

         { redc(x, ws); }

The documentation for this class was generated from the following files: