Botan 3.7.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
16#if defined(BOTAN_HAS_LEGACY_EC_POINT)
17 #include <botan/ec_point.h>
18#endif
19
20namespace Botan {
21
22class RandomNumberGenerator;
23
25 public:
26 EC_PublicKey_Data(EC_Group group, EC_AffinePoint pt) : m_group(std::move(group)), m_point(std::move(pt)) {
27#if defined(BOTAN_HAS_LEGACY_EC_POINT)
28 m_legacy_point = m_point.to_legacy_point();
29#endif
30 }
31
32 EC_PublicKey_Data(EC_Group group, std::span<const uint8_t> bytes);
33
34 const EC_Group& group() const { return m_group; }
35
36 const EC_AffinePoint& public_key() const { return m_point; }
37
38#if defined(BOTAN_HAS_LEGACY_EC_POINT)
39 const EC_Point& legacy_point() const { return m_legacy_point; }
40#endif
41
42 private:
43 EC_Group m_group;
44 EC_AffinePoint m_point;
45#if defined(BOTAN_HAS_LEGACY_EC_POINT)
46 EC_Point m_legacy_point;
47#endif
48};
49
51 public:
53
54 EC_PrivateKey_Data(EC_Group group, std::span<const uint8_t> bytes);
55
56 std::shared_ptr<EC_PublicKey_Data> public_key(RandomNumberGenerator& rng, bool with_modular_inverse) const;
57
58 std::shared_ptr<EC_PublicKey_Data> public_key(bool with_modular_inverse) const;
59
60 void serialize_to(std::span<uint8_t> output) const;
61
62 template <typename T>
63 T serialize() const {
64 T bytes(this->group().get_order_bytes());
65 this->serialize_to(bytes);
66 return bytes;
67 }
68
69 const EC_Group& group() const { return m_group; }
70
71 const EC_Scalar& private_key() const { return m_scalar; }
72
73 const BigInt& legacy_bigint() const { return m_legacy_x; }
74
75 private:
76 EC_Group m_group;
77
78 EC_Scalar m_scalar;
79 BigInt m_legacy_x;
80};
81
82} // namespace Botan
83
84#endif
const EC_Scalar & private_key() const
Definition ec_key_data.h:71
const EC_Group & group() const
Definition ec_key_data.h:69
void serialize_to(std::span< uint8_t > output) const
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:73
EC_PrivateKey_Data(EC_Group group, EC_Scalar x)
const EC_AffinePoint & public_key() const
Definition ec_key_data.h:36
const EC_Group & group() const
Definition ec_key_data.h:34
EC_PublicKey_Data(EC_Group group, EC_AffinePoint pt)
Definition ec_key_data.h:26
int(* final)(unsigned char *, CTX *)
FE_25519 T
Definition ge.cpp:34