Botan 3.8.1
Crypto and TLS for C&
x448.h
Go to the documentation of this file.
1/*
2* X448
3* (C) 2024 Jack Lloyd
4* 2024 Fabian Albert - Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8#ifndef BOTAN_X448_H_
9#define BOTAN_X448_H_
10
11#include <botan/pk_keys.h>
12
13#include <array>
14
15namespace Botan {
16/**
17 * @brief A public key for the X448 key agreement scheme according to RFC 7748.
18 */
19class BOTAN_PUBLIC_API(3, 4) X448_PublicKey : public virtual Public_Key {
20 public:
21 /**
22 * Create a X448 Public Key.
23 * @param alg_id the X.509 algorithm identifier
24 * @param key_bits DER encoded public key bits
25 */
26 X448_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
27
28 /**
29 * Create a X448 Public Key.
30 * @param pub 56-byte raw public key
31 */
32 explicit X448_PublicKey(std::span<const uint8_t> pub);
33
34 std::string algo_name() const override { return "X448"; }
35
36 size_t estimated_strength() const override { return 224; }
37
38 size_t key_length() const override { return 448; }
39
40 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
41
42 AlgorithmIdentifier algorithm_identifier() const override;
43
44 BOTAN_DEPRECATED("Use raw_public_key_bits") std::vector<uint8_t> public_value() const {
45 return raw_public_key_bits();
46 }
47
48 std::vector<uint8_t> raw_public_key_bits() const override;
49
50 std::vector<uint8_t> public_key_bits() const override;
51
53
54 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
55
56 protected:
57 X448_PublicKey() = default;
58 std::array<uint8_t, 56> m_public;
59};
60
63
64/**
65 * @brief A private key for the X448 key agreement scheme according to RFC 7748.
66 */
68 public virtual Private_Key,
69 public virtual PK_Key_Agreement_Key {
70 public:
71 /**
72 * Construct a private key from the specified parameters.
73 * @param alg_id the X.509 algorithm identifier
74 * @param key_bits PKCS #8 structure
75 */
76 X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
77
78 /**
79 * Generate a private key.
80 * @param rng the RNG to use
81 */
83
84 /**
85 * Construct a private key from the specified parameters.
86 * @param secret_key the private key
87 */
88 explicit X448_PrivateKey(std::span<const uint8_t> secret_key);
89
90 std::vector<uint8_t> public_value() const override { return raw_public_key_bits(); }
91
92 secure_vector<uint8_t> raw_private_key_bits() const override { return {m_private.begin(), m_private.end()}; }
93
94 secure_vector<uint8_t> private_key_bits() const override;
95
96 std::unique_ptr<Public_Key> public_key() const override;
97
98 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
99
100 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
101 std::string_view params,
102 std::string_view provider) const override;
103
104 private:
105 secure_vector<uint8_t> m_private;
106};
107
109
110} // namespace Botan
111
112#endif
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:108
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:105
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:107
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:19
#define BOTAN_DEPRECATED(msg)
Definition api.h:59
secure_vector< uint8_t > raw_private_key_bits() const override
Definition x448.h:92
X448_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition x448.cpp:65
std::vector< uint8_t > public_value() const override
Definition x448.h:90
bool supports_operation(PublicKeyOperation op) const override
Definition x448.h:52
std::vector< uint8_t > raw_public_key_bits() const override
Definition x448.cpp:45
std::vector< uint8_t > public_value() const
Definition x448.h:44
std::array< uint8_t, 56 > m_public
Definition x448.h:58
size_t key_length() const override
Definition x448.h:38
X448_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition x448.cpp:57
size_t estimated_strength() const override
Definition x448.h:36
std::string algo_name() const override
Definition x448.h:34
PublicKeyOperation
Definition pk_keys.h:46
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:65