Botan 3.6.1
Crypto and TLS for C&
ec_inner_pc.h
Go to the documentation of this file.
1/*
2* (C) 2024 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_EC_INNER_DATA_PC_H_
8#define BOTAN_EC_INNER_DATA_PC_H_
9
10#include <botan/internal/ec_inner_data.h>
11
12#include <botan/internal/pcurves.h>
13
14namespace Botan {
15
17 public:
18 EC_Scalar_Data_PC(std::shared_ptr<const EC_Group_Data> group, PCurve::PrimeOrderCurve::Scalar v) :
19 m_group(std::move(group)), m_v(std::move(v)) {}
20
21 static const EC_Scalar_Data_PC& checked_ref(const EC_Scalar_Data& data);
22
23 const std::shared_ptr<const EC_Group_Data>& group() const override;
24
25 std::unique_ptr<EC_Scalar_Data> clone() const override;
26
27 size_t bytes() const override;
28
29 bool is_zero() const override;
30
31 bool is_eq(const EC_Scalar_Data& y) const override;
32
33 void assign(const EC_Scalar_Data& y) override;
34
35 void square_self() override;
36
37 std::unique_ptr<EC_Scalar_Data> negate() const override;
38
39 std::unique_ptr<EC_Scalar_Data> invert() const override;
40
41 std::unique_ptr<EC_Scalar_Data> add(const EC_Scalar_Data& other) const override;
42
43 std::unique_ptr<EC_Scalar_Data> sub(const EC_Scalar_Data& other) const override;
44
45 std::unique_ptr<EC_Scalar_Data> mul(const EC_Scalar_Data& other) const override;
46
47 void serialize_to(std::span<uint8_t> bytes) const override;
48
49 const auto& value() const { return m_v; }
50
51 private:
52 std::shared_ptr<const EC_Group_Data> m_group;
54};
55
57 public:
58 EC_AffinePoint_Data_PC(std::shared_ptr<const EC_Group_Data> group, PCurve::PrimeOrderCurve::AffinePoint pt);
59
60 EC_AffinePoint_Data_PC(std::shared_ptr<const EC_Group_Data> group, std::span<const uint8_t> pt);
61
63
64 const std::shared_ptr<const EC_Group_Data>& group() const override;
65
66 std::unique_ptr<EC_AffinePoint_Data> clone() const override;
67
68 size_t field_element_bytes() const override;
69
70 bool is_identity() const override;
71
72 void serialize_x_to(std::span<uint8_t> bytes) const override;
73
74 void serialize_y_to(std::span<uint8_t> bytes) const override;
75
76 void serialize_xy_to(std::span<uint8_t> bytes) const override;
77
78 void serialize_compressed_to(std::span<uint8_t> bytes) const override;
79
80 void serialize_uncompressed_to(std::span<uint8_t> bytes) const override;
81
82 std::unique_ptr<EC_AffinePoint_Data> mul(const EC_Scalar_Data& scalar,
84 std::vector<BigInt>& ws) const override;
85
86 const PCurve::PrimeOrderCurve::AffinePoint& value() const { return m_pt; }
87
88 EC_Point to_legacy_point() const override;
89
90 private:
91 std::shared_ptr<const EC_Group_Data> m_group;
93 secure_vector<uint8_t> m_xy; // empty if point is identity
94};
95
97 public:
99
100 std::unique_ptr<EC_AffinePoint_Data> mul2_vartime(const EC_Scalar_Data& x,
101 const EC_Scalar_Data& y) const override;
102
104 const EC_Scalar_Data& x,
105 const EC_Scalar_Data& y) const override;
106
107 private:
108 std::shared_ptr<const EC_Group_Data> m_group;
109 std::unique_ptr<const PCurve::PrimeOrderCurve::PrecomputedMul2Table> m_tbl;
110};
111
112} // namespace Botan
113
114#endif
size_t field_element_bytes() const override
void serialize_uncompressed_to(std::span< uint8_t > bytes) const override
void serialize_xy_to(std::span< uint8_t > bytes) const override
std::unique_ptr< EC_AffinePoint_Data > mul(const EC_Scalar_Data &scalar, RandomNumberGenerator &rng, std::vector< BigInt > &ws) const override
std::unique_ptr< EC_AffinePoint_Data > clone() const override
const std::shared_ptr< const EC_Group_Data > & group() const override
EC_AffinePoint_Data_PC(std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::AffinePoint pt)
EC_Point to_legacy_point() const override
const PCurve::PrimeOrderCurve::AffinePoint & value() const
Definition ec_inner_pc.h:86
bool is_identity() const override
void serialize_x_to(std::span< uint8_t > bytes) const override
void serialize_y_to(std::span< uint8_t > bytes) const override
static const EC_AffinePoint_Data_PC & checked_ref(const EC_AffinePoint_Data &data)
void serialize_compressed_to(std::span< uint8_t > bytes) const override
bool mul2_vartime_x_mod_order_eq(const EC_Scalar_Data &v, const EC_Scalar_Data &x, const EC_Scalar_Data &y) const override
EC_Mul2Table_Data_PC(const EC_AffinePoint_Data &g, const EC_AffinePoint_Data &h)
std::unique_ptr< EC_AffinePoint_Data > mul2_vartime(const EC_Scalar_Data &x, const EC_Scalar_Data &y) const override
void serialize_to(std::span< uint8_t > bytes) const override
std::unique_ptr< EC_Scalar_Data > invert() const override
void assign(const EC_Scalar_Data &y) override
size_t bytes() const override
static const EC_Scalar_Data_PC & checked_ref(const EC_Scalar_Data &data)
std::unique_ptr< EC_Scalar_Data > sub(const EC_Scalar_Data &other) const override
bool is_eq(const EC_Scalar_Data &y) const override
void square_self() override
std::unique_ptr< EC_Scalar_Data > clone() const override
EC_Scalar_Data_PC(std::shared_ptr< const EC_Group_Data > group, PCurve::PrimeOrderCurve::Scalar v)
Definition ec_inner_pc.h:18
std::unique_ptr< EC_Scalar_Data > mul(const EC_Scalar_Data &other) const override
const std::shared_ptr< const EC_Group_Data > & group() const override
std::unique_ptr< EC_Scalar_Data > negate() const override
bool is_zero() const override
std::unique_ptr< EC_Scalar_Data > add(const EC_Scalar_Data &other) const override
const auto & value() const
Definition ec_inner_pc.h:49
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61