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

#include <ec_inner_pc.h>

Inheritance diagram for Botan::EC_Scalar_Data_PC:
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_PC (std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::Scalar 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 auto & value () const
 

Static Public Member Functions

static const EC_Scalar_Data_PCchecked_ref (const EC_Scalar_Data &data)
 

Detailed Description

Definition at line 16 of file ec_inner_pc.h.

Constructor & Destructor Documentation

◆ EC_Scalar_Data_PC()

Botan::EC_Scalar_Data_PC::EC_Scalar_Data_PC ( std::shared_ptr< const EC_Group_Data > group,
PCurve::PrimeOrderCurve::Scalar v )
inline

Definition at line 18 of file ec_inner_pc.h.

18 :
19 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_PC::add ( const EC_Scalar_Data & other) const
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 69 of file ec_inner_pc.cpp.

69 {
70 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_v + checked_ref(other).value());
71}
static const EC_Scalar_Data_PC & checked_ref(const EC_Scalar_Data &data)
const auto & value() const
Definition ec_inner_pc.h:49

References checked_ref(), and value().

◆ assign()

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

Implements Botan::EC_Scalar_Data.

Definition at line 52 of file ec_inner_pc.cpp.

52 {
53 m_v = checked_ref(other).value();
54}

References checked_ref(), and value().

◆ bytes()

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

Implements Botan::EC_Scalar_Data.

Definition at line 36 of file ec_inner_pc.cpp.

36 {
37 return this->group()->order_bytes();
38}

References group().

Referenced by serialize_to().

◆ checked_ref()

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

Definition at line 24 of file ec_inner_pc.cpp.

24 {
25 const auto* p = dynamic_cast<const EC_Scalar_Data_PC*>(&data);
26 if(!p) {
27 throw Invalid_State("Failed conversion to EC_Scalar_Data_PC");
28 }
29 return *p;
30}
EC_Scalar_Data_PC(std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::Scalar v)
Definition ec_inner_pc.h:18

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

◆ clone()

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

Implements Botan::EC_Scalar_Data.

Definition at line 40 of file ec_inner_pc.cpp.

40 {
41 return std::make_unique<EC_Scalar_Data_PC>(this->group(), this->value());
42}

References group(), and value().

◆ group()

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

Implements Botan::EC_Scalar_Data.

Definition at line 32 of file ec_inner_pc.cpp.

32 {
33 return m_group;
34}

Referenced by bytes(), and clone().

◆ invert()

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

Implements Botan::EC_Scalar_Data.

Definition at line 65 of file ec_inner_pc.cpp.

65 {
66 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_v.invert());
67}

References Botan::PCurve::PrimeOrderCurve::Scalar::invert().

◆ is_eq()

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

Implements Botan::EC_Scalar_Data.

Definition at line 48 of file ec_inner_pc.cpp.

48 {
49 return (value() == checked_ref(other).value());
50}

References checked_ref(), and value().

◆ is_zero()

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

Implements Botan::EC_Scalar_Data.

Definition at line 44 of file ec_inner_pc.cpp.

44 {
45 return this->value().is_zero();
46}

References value().

◆ mul()

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

Implements Botan::EC_Scalar_Data.

Definition at line 77 of file ec_inner_pc.cpp.

77 {
78 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_v * checked_ref(other).value());
79}

References checked_ref(), and value().

◆ negate()

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

Implements Botan::EC_Scalar_Data.

Definition at line 61 of file ec_inner_pc.cpp.

61 {
62 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_v.negate());
63}

References Botan::PCurve::PrimeOrderCurve::Scalar::negate().

◆ serialize_to()

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

Implements Botan::EC_Scalar_Data.

Definition at line 81 of file ec_inner_pc.cpp.

81 {
82 BOTAN_ARG_CHECK(bytes.size() == m_group->order_bytes(), "Invalid output length");
83 m_group->pcurve().serialize_scalar(bytes, m_v);
84}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
size_t bytes() const override

References BOTAN_ARG_CHECK, and bytes().

◆ square_self()

void Botan::EC_Scalar_Data_PC::square_self ( )
overridevirtual

Implements Botan::EC_Scalar_Data.

Definition at line 56 of file ec_inner_pc.cpp.

56 {
57 // TODO square in place
58 m_v = m_v.square();
59}

References Botan::PCurve::PrimeOrderCurve::Scalar::square().

◆ sub()

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

Implements Botan::EC_Scalar_Data.

Definition at line 73 of file ec_inner_pc.cpp.

73 {
74 return std::make_unique<EC_Scalar_Data_PC>(m_group, m_v - checked_ref(other).value());
75}

References checked_ref(), and value().

◆ value()

const auto & Botan::EC_Scalar_Data_PC::value ( ) const
inline

Definition at line 49 of file ec_inner_pc.h.

49{ return m_v; }

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


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