Botan 3.6.1
Crypto and TLS for C&
Botan::EC_Scalar_Data_BN Class Referencefinal

#include <ec_inner_bn.h>

Inheritance diagram for Botan::EC_Scalar_Data_BN:
Botan::EC_Scalar_Data

Public Member Functions

std::unique_ptr< EC_Scalar_Dataadd (const EC_Scalar_Data &other) const override
 
void assign (const EC_Scalar_Data &y) override
 
size_t bytes () const override
 
std::unique_ptr< EC_Scalar_Dataclone () const override
 
 EC_Scalar_Data_BN (std::shared_ptr< const EC_Group_Data > group, BigInt v)
 
const std::shared_ptr< const EC_Group_Data > & group () const override
 
std::unique_ptr< EC_Scalar_Datainvert () const override
 
bool is_eq (const EC_Scalar_Data &y) const override
 
bool is_zero () const override
 
std::unique_ptr< EC_Scalar_Datamul (const EC_Scalar_Data &other) const override
 
std::unique_ptr< EC_Scalar_Datanegate () const override
 
void serialize_to (std::span< uint8_t > bytes) const override
 
void square_self () override
 
std::unique_ptr< EC_Scalar_Datasub (const EC_Scalar_Data &other) const override
 
const BigIntvalue () const
 

Static Public Member Functions

static const EC_Scalar_Data_BNchecked_ref (const EC_Scalar_Data &data)
 

Detailed Description

Definition at line 15 of file ec_inner_bn.h.

Constructor & Destructor Documentation

◆ EC_Scalar_Data_BN()

Botan::EC_Scalar_Data_BN::EC_Scalar_Data_BN ( std::shared_ptr< const EC_Group_Data > group,
BigInt v )
inline

Definition at line 17 of file ec_inner_bn.h.

17 :
18 m_group(std::move(group)), m_v(std::move(v)) {}
const std::shared_ptr< const EC_Group_Data > & group() const override

Member Function Documentation

◆ add()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::add ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 55 of file ec_inner_bn.cpp.

55 {
56 return std::make_unique<EC_Scalar_Data_BN>(m_group, m_group->mod_order(m_v + checked_ref(other).value()));
57}
const BigInt & value() const
Definition ec_inner_bn.h:48
static const EC_Scalar_Data_BN & checked_ref(const EC_Scalar_Data &data)

References checked_ref(), and value().

◆ assign()

void Botan::EC_Scalar_Data_BN::assign ( const EC_Scalar_Data & y)
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 39 of file ec_inner_bn.cpp.

39 {
40 m_v = checked_ref(other).value();
41}

References checked_ref(), and value().

◆ bytes()

size_t Botan::EC_Scalar_Data_BN::bytes ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 23 of file ec_inner_bn.cpp.

23 {
24 return this->group()->order_bytes();
25}

References group().

Referenced by serialize_to().

◆ checked_ref()

const EC_Scalar_Data_BN & Botan::EC_Scalar_Data_BN::checked_ref ( const EC_Scalar_Data & data)
static

Definition at line 11 of file ec_inner_bn.cpp.

11 {
12 const auto* p = dynamic_cast<const EC_Scalar_Data_BN*>(&data);
13 if(!p) {
14 throw Invalid_State("Failed conversion to EC_Scalar_Data_BN");
15 }
16 return *p;
17}
EC_Scalar_Data_BN(std::shared_ptr< const EC_Group_Data > group, BigInt v)
Definition ec_inner_bn.h:17

Referenced by add(), assign(), is_eq(), Botan::EC_AffinePoint_Data_BN::mul(), mul(), Botan::EC_Mul2Table_Data_BN::mul2_vartime(), Botan::EC_Mul2Table_Data_BN::mul2_vartime_x_mod_order_eq(), and sub().

◆ clone()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::clone ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 27 of file ec_inner_bn.cpp.

27 {
28 return std::make_unique<EC_Scalar_Data_BN>(this->group(), this->value());
29}

References group(), and value().

◆ group()

const std::shared_ptr< const EC_Group_Data > & Botan::EC_Scalar_Data_BN::group ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 19 of file ec_inner_bn.cpp.

19 {
20 return m_group;
21}

Referenced by bytes(), and clone().

◆ invert()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::invert ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 51 of file ec_inner_bn.cpp.

51 {
52 return std::make_unique<EC_Scalar_Data_BN>(m_group, m_group->inverse_mod_order(m_v));
53}

◆ is_eq()

bool Botan::EC_Scalar_Data_BN::is_eq ( const EC_Scalar_Data & y) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 35 of file ec_inner_bn.cpp.

35 {
36 return (value() == checked_ref(other).value());
37}

References checked_ref(), and value().

◆ is_zero()

bool Botan::EC_Scalar_Data_BN::is_zero ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 31 of file ec_inner_bn.cpp.

31 {
32 return this->value().is_zero();
33}
bool is_zero() const
Definition bigint.h:458

References Botan::BigInt::is_zero(), and value().

◆ mul()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::mul ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 63 of file ec_inner_bn.cpp.

63 {
64 return std::make_unique<EC_Scalar_Data_BN>(m_group, m_group->multiply_mod_order(m_v, checked_ref(other).value()));
65}

References checked_ref(), and value().

◆ negate()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::negate ( ) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 47 of file ec_inner_bn.cpp.

47 {
48 return std::make_unique<EC_Scalar_Data_BN>(m_group, m_group->mod_order(-m_v));
49}

◆ serialize_to()

void Botan::EC_Scalar_Data_BN::serialize_to ( std::span< uint8_t > bytes) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 67 of file ec_inner_bn.cpp.

67 {
68 BOTAN_ARG_CHECK(bytes.size() == m_group->order_bytes(), "Invalid output length");
70}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
void serialize_to(std::span< uint8_t > out) const
Definition bigint.cpp:383
size_t bytes() const override

References BOTAN_ARG_CHECK, bytes(), and Botan::BigInt::serialize_to().

◆ square_self()

void Botan::EC_Scalar_Data_BN::square_self ( )
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 43 of file ec_inner_bn.cpp.

43 {
44 m_group->square_mod_order(m_v);
45}

◆ sub()

std::unique_ptr< EC_Scalar_Data > Botan::EC_Scalar_Data_BN::sub ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 59 of file ec_inner_bn.cpp.

59 {
60 return std::make_unique<EC_Scalar_Data_BN>(m_group, m_group->mod_order(m_v - checked_ref(other).value()));
61}

References checked_ref(), and value().

◆ value()

const BigInt & Botan::EC_Scalar_Data_BN::value ( ) const
inline

Definition at line 48 of file ec_inner_bn.h.

48{ return m_v; }

Referenced by add(), assign(), clone(), is_eq(), is_zero(), mul(), and sub().


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