Botan 3.6.1
Crypto and TLS for C&
ec_inner_bn.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_BN_H_
8#define BOTAN_EC_INNER_DATA_BN_H_
9
10#include <botan/internal/ec_inner_data.h>
11#include <botan/internal/point_mul.h>
12
13namespace Botan {
14
16 public:
17 EC_Scalar_Data_BN(std::shared_ptr<const EC_Group_Data> group, BigInt v) :
18 m_group(std::move(group)), m_v(std::move(v)) {}
19
20 static const EC_Scalar_Data_BN& checked_ref(const EC_Scalar_Data& data);
21
22 const std::shared_ptr<const EC_Group_Data>& group() const override;
23
24 std::unique_ptr<EC_Scalar_Data> clone() const override;
25
26 size_t bytes() const override;
27
28 bool is_zero() const override;
29
30 bool is_eq(const EC_Scalar_Data& y) const override;
31
32 void assign(const EC_Scalar_Data& y) override;
33
34 void square_self() override;
35
36 std::unique_ptr<EC_Scalar_Data> negate() const override;
37
38 std::unique_ptr<EC_Scalar_Data> invert() const override;
39
40 std::unique_ptr<EC_Scalar_Data> add(const EC_Scalar_Data& other) const override;
41
42 std::unique_ptr<EC_Scalar_Data> sub(const EC_Scalar_Data& other) const override;
43
44 std::unique_ptr<EC_Scalar_Data> mul(const EC_Scalar_Data& other) const override;
45
46 void serialize_to(std::span<uint8_t> bytes) const override;
47
48 const BigInt& value() const { return m_v; }
49
50 private:
51 std::shared_ptr<const EC_Group_Data> m_group;
52 BigInt m_v;
53};
54
56 public:
57 EC_AffinePoint_Data_BN(std::shared_ptr<const EC_Group_Data> group, EC_Point pt);
58
59 EC_AffinePoint_Data_BN(std::shared_ptr<const EC_Group_Data> group, std::span<const uint8_t> pt);
60
61 const std::shared_ptr<const EC_Group_Data>& group() const override;
62
63 std::unique_ptr<EC_AffinePoint_Data> clone() const override;
64
65 size_t field_element_bytes() const override;
66
67 bool is_identity() const override;
68
69 void serialize_x_to(std::span<uint8_t> bytes) const override;
70
71 void serialize_y_to(std::span<uint8_t> bytes) const override;
72
73 void serialize_xy_to(std::span<uint8_t> bytes) const override;
74
75 void serialize_compressed_to(std::span<uint8_t> bytes) const override;
76
77 void serialize_uncompressed_to(std::span<uint8_t> bytes) const override;
78
79 std::unique_ptr<EC_AffinePoint_Data> mul(const EC_Scalar_Data& scalar,
81 std::vector<BigInt>& ws) const override;
82
83 EC_Point to_legacy_point() const override { return m_pt; }
84
85 private:
86 std::shared_ptr<const EC_Group_Data> m_group;
87 EC_Point m_pt;
88 secure_vector<uint8_t> m_xy; // empty if point is identity element
89};
90
92 public:
94
95 std::unique_ptr<EC_AffinePoint_Data> mul2_vartime(const EC_Scalar_Data& x,
96 const EC_Scalar_Data& y) const override;
97
99 const EC_Scalar_Data& x,
100 const EC_Scalar_Data& y) const override;
101
102 private:
103 std::shared_ptr<const EC_Group_Data> m_group;
105};
106
107} // namespace Botan
108
109#endif
void serialize_x_to(std::span< uint8_t > bytes) const override
const std::shared_ptr< const EC_Group_Data > & group() const override
EC_Point to_legacy_point() const override
Definition ec_inner_bn.h:83
EC_AffinePoint_Data_BN(std::shared_ptr< const EC_Group_Data > group, EC_Point pt)
void serialize_compressed_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
size_t field_element_bytes() const override
bool is_identity() const override
void serialize_y_to(std::span< uint8_t > bytes) const override
void serialize_xy_to(std::span< uint8_t > bytes) const override
void serialize_uncompressed_to(std::span< uint8_t > bytes) const override
EC_Mul2Table_Data_BN(const EC_AffinePoint_Data &g, const EC_AffinePoint_Data &h)
bool mul2_vartime_x_mod_order_eq(const EC_Scalar_Data &v, const EC_Scalar_Data &x, const EC_Scalar_Data &y) const override
std::unique_ptr< EC_AffinePoint_Data > mul2_vartime(const EC_Scalar_Data &x, const EC_Scalar_Data &y) const override
std::unique_ptr< EC_Scalar_Data > invert() const override
std::unique_ptr< EC_Scalar_Data > clone() const override
std::unique_ptr< EC_Scalar_Data > negate() const override
const std::shared_ptr< const EC_Group_Data > & group() const override
bool is_zero() const override
std::unique_ptr< EC_Scalar_Data > sub(const EC_Scalar_Data &other) const override
void square_self() override
std::unique_ptr< EC_Scalar_Data > add(const EC_Scalar_Data &other) const override
std::unique_ptr< EC_Scalar_Data > mul(const EC_Scalar_Data &other) const override
const BigInt & value() const
Definition ec_inner_bn.h:48
void serialize_to(std::span< uint8_t > bytes) const override
static const EC_Scalar_Data_BN & checked_ref(const EC_Scalar_Data &data)
EC_Scalar_Data_BN(std::shared_ptr< const EC_Group_Data > group, BigInt v)
Definition ec_inner_bn.h:17
bool is_eq(const EC_Scalar_Data &y) const override
void assign(const EC_Scalar_Data &y) override
size_t bytes() const override
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61