Botan 3.6.1
Crypto and TLS for C&
ec_key_data.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_KEY_DATA_H_
8#define BOTAN_EC_KEY_DATA_H_
9
10#include <botan/ec_apoint.h>
11#include <botan/ec_group.h>
12#include <botan/ec_scalar.h>
13
14#include <botan/bigint.h>
15#include <botan/ec_point.h>
16
17namespace Botan {
18
19class RandomNumberGenerator;
20
22 public:
24 m_group(std::move(group)), m_point(std::move(pt)), m_legacy_point(m_point.to_legacy_point()) {}
25
26 EC_PublicKey_Data(EC_Group group, std::span<const uint8_t> bytes);
27
28 const EC_Group& group() const { return m_group; }
29
30 const EC_AffinePoint& public_key() const { return m_point; }
31
32 const EC_Point& legacy_point() const { return m_legacy_point; }
33
34 private:
35 EC_Group m_group;
36 EC_AffinePoint m_point;
37 EC_Point m_legacy_point;
38};
39
41 public:
43
45
47
48 EC_PrivateKey_Data(EC_Group group, std::span<const uint8_t> bytes);
49
50 std::shared_ptr<EC_PublicKey_Data> public_key(RandomNumberGenerator& rng, bool with_modular_inverse) const;
51
52 std::shared_ptr<EC_PublicKey_Data> public_key(bool with_modular_inverse) const;
53
54 void serialize_to(std::span<uint8_t> output) const;
55
56 template <typename T>
57 T serialize() const {
58 T bytes(this->group().get_order_bytes());
59 this->serialize_to(bytes);
60 return bytes;
61 }
62
63 const EC_Group& group() const { return m_group; }
64
65 const EC_Scalar& private_key() const { return m_scalar; }
66
67 const BigInt& legacy_bigint() const { return m_legacy_x; }
68
69 private:
70 EC_Group m_group;
71
72 EC_Scalar m_scalar;
73 BigInt m_legacy_x;
74};
75
76} // namespace Botan
77
78#endif
const EC_Scalar & private_key() const
Definition ec_key_data.h:65
const EC_Group & group() const
Definition ec_key_data.h:63
void serialize_to(std::span< uint8_t > output) const
EC_PrivateKey_Data(EC_Group group, RandomNumberGenerator &rng)
std::shared_ptr< EC_PublicKey_Data > public_key(RandomNumberGenerator &rng, bool with_modular_inverse) const
const BigInt & legacy_bigint() const
Definition ec_key_data.h:67
const EC_Point & legacy_point() const
Definition ec_key_data.h:32
const EC_AffinePoint & public_key() const
Definition ec_key_data.h:30
const EC_Group & group() const
Definition ec_key_data.h:28
EC_PublicKey_Data(EC_Group group, EC_AffinePoint pt)
Definition ec_key_data.h:23
int(* final)(unsigned char *, CTX *)
FE_25519 T
Definition ge.cpp:34