Botan 3.13.0
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 <memory>
14#include <vector>
15
16namespace Botan {
17
18class X448_PublicKey_Data;
19class X448_PrivateKey_Data;
20
21/**
22 * @brief A public key for the X448 key agreement scheme according to RFC 7748.
23 */
24class BOTAN_PUBLIC_API(3, 4) X448_PublicKey : public virtual Public_Key {
25 public:
26 /**
27 * Create a X448 Public Key.
28 * @param alg_id the X.509 algorithm identifier
29 * @param key_bits DER encoded public key bits
30 */
31 X448_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
32
33 /**
34 * Create a X448 Public Key.
35 * @param pub 56-byte raw public key
36 */
37 explicit X448_PublicKey(std::span<const uint8_t> pub);
38
39 std::string algo_name() const override { return "X448"; }
40
41 size_t estimated_strength() const override { return 224; }
42
43 size_t key_length() const override { return 448; }
44
45 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
46
47 AlgorithmIdentifier algorithm_identifier() const override;
48
49 BOTAN_DEPRECATED("Use raw_public_key_bits") std::vector<uint8_t> public_value() const {
50 return raw_public_key_bits();
51 }
52
53 std::vector<uint8_t> raw_public_key_bits() const override;
54
55 std::vector<uint8_t> public_key_bits() const override;
56
58
59 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
60
61 protected:
62 X448_PublicKey() = default;
63 std::shared_ptr<const X448_PublicKey_Data> m_public; // NOLINT(*non-private-member-variable*)
64};
65
68
69/**
70 * @brief A private key for the X448 key agreement scheme according to RFC 7748.
71 */
73 public virtual Private_Key,
74 public virtual PK_Key_Agreement_Key {
75 public:
76 /**
77 * Construct a private key from the specified parameters.
78 * @param alg_id the X.509 algorithm identifier
79 * @param key_bits PKCS #8 structure
80 */
81 X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
82
83 /**
84 * Generate a private key.
85 * @param rng the RNG to use
86 */
88
89 /**
90 * Construct a private key from the specified parameters.
91 * @param secret_key the private key
92 */
93 explicit X448_PrivateKey(std::span<const uint8_t> secret_key);
94
95 std::vector<uint8_t> public_value() const override { return raw_public_key_bits(); }
96
97 secure_vector<uint8_t> raw_private_key_bits() const override;
98
99 secure_vector<uint8_t> private_key_bits() const override;
100
101 std::unique_ptr<Public_Key> public_key() const override;
102
103 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
104
105 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
106 std::string_view params,
107 std::string_view provider) const override;
108
109 private:
110 std::shared_ptr<const X448_PrivateKey_Data> m_private;
111};
112
114
115} // namespace Botan
116
117#endif
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:128
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:125
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:127
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_DEPRECATED(msg)
Definition api.h:73
X448_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition x448.cpp:116
std::vector< uint8_t > public_value() const override
Definition x448.h:95
bool supports_operation(PublicKeyOperation op) const override
Definition x448.h:57
std::vector< uint8_t > raw_public_key_bits() const override
Definition x448.cpp:88
std::vector< uint8_t > public_value() const
Definition x448.h:49
size_t key_length() const override
Definition x448.h:43
std::shared_ptr< const X448_PublicKey_Data > m_public
Definition x448.h:63
X448_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition x448.cpp:101
size_t estimated_strength() const override
Definition x448.h:41
std::string algo_name() const override
Definition x448.h:39
PublicKeyOperation
Definition pk_keys.h:46
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128