Botan 3.6.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 <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 std::vector<uint8_t> public_value() const { return {m_public.begin(), m_public.end()}; }
45
46 std::vector<uint8_t> raw_public_key_bits() const override;
47
48 std::vector<uint8_t> public_key_bits() const override;
49
50 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::KeyAgreement); }
51
52 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
53
54 protected:
55 X448_PublicKey() = default;
56 std::array<uint8_t, 56> m_public;
57};
58
61
62/**
63 * @brief A private key for the X448 key agreement scheme according to RFC 7748.
64 */
66 public virtual Private_Key,
67 public virtual PK_Key_Agreement_Key {
68 public:
69 /**
70 * Construct a private key from the specified parameters.
71 * @param alg_id the X.509 algorithm identifier
72 * @param key_bits PKCS #8 structure
73 */
74 X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
75
76 /**
77 * Generate a private key.
78 * @param rng the RNG to use
79 */
81
82 /**
83 * Construct a private key from the specified parameters.
84 * @param secret_key the private key
85 */
86 explicit X448_PrivateKey(std::span<const uint8_t> secret_key);
87
88 std::vector<uint8_t> public_value() const override { return X448_PublicKey::public_key_bits(); }
89
90 secure_vector<uint8_t> raw_private_key_bits() const override { return {m_private.begin(), m_private.end()}; }
91
92 secure_vector<uint8_t> private_key_bits() const override;
93
94 std::unique_ptr<Public_Key> public_key() const override;
95
96 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
97
98 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
99 std::string_view params,
100 std::string_view provider) const override;
101
102 private:
103 secure_vector<uint8_t> m_private;
104};
105
107
108} // namespace Botan
109
110#endif
A private key for the X448 key agreement scheme according to RFC 7748.
Definition x448.h:67
secure_vector< uint8_t > raw_private_key_bits() const override
Definition x448.h:90
std::vector< uint8_t > public_value() const override
Definition x448.h:88
A public key for the X448 key agreement scheme according to RFC 7748.
Definition x448.h:19
bool supports_operation(PublicKeyOperation op) const override
Definition x448.h:50
std::vector< uint8_t > public_value() const
Definition x448.h:44
std::array< uint8_t, 56 > m_public
Definition x448.h:56
size_t key_length() const override
Definition x448.h:38
size_t estimated_strength() const override
Definition x448.h:36
std::string algo_name() const override
Definition x448.h:34
int(* final)(unsigned char *, CTX *)
#define BOTAN_DIAGNOSTIC_POP
Definition compiler.h:191
#define BOTAN_DIAGNOSTIC_PUSH
Definition compiler.h:188
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition compiler.h:190
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31
PublicKeyOperation
Definition pk_keys.h:45
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61