Botan 3.4.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 Curve25519 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> public_key_bits() const override;
47
48 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::KeyAgreement); }
49
50 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
51
52 protected:
53 X448_PublicKey() = default;
54 std::array<uint8_t, 56> m_public;
55};
56
59
60/**
61 * @brief A private key for the X448 key agreement scheme according to RFC 7748.
62 */
64 public virtual Private_Key,
65 public virtual PK_Key_Agreement_Key {
66 public:
67 /**
68 * Construct a private key from the specified parameters.
69 * @param alg_id the X.509 algorithm identifier
70 * @param key_bits PKCS #8 structure
71 */
72 X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
73
74 /**
75 * Generate a private key.
76 * @param rng the RNG to use
77 */
79
80 /**
81 * Construct a private key from the specified parameters.
82 * @param secret_key the private key
83 */
84 explicit X448_PrivateKey(std::span<const uint8_t> secret_key);
85
86 std::vector<uint8_t> public_value() const override { return X448_PublicKey::public_key_bits(); }
87
88 secure_vector<uint8_t> raw_private_key_bits() const override { return {m_private.begin(), m_private.end()}; }
89
90 secure_vector<uint8_t> private_key_bits() const override;
91
92 std::unique_ptr<Public_Key> public_key() const override;
93
94 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
95
96 std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
97 std::string_view params,
98 std::string_view provider) const override;
99
100 private:
101 secure_vector<uint8_t> m_private;
102};
103
105
106} // namespace Botan
107
108#endif
A private key for the X448 key agreement scheme according to RFC 7748.
Definition x448.h:65
secure_vector< uint8_t > raw_private_key_bits() const override
Definition x448.h:88
std::vector< uint8_t > public_value() const override
Definition x448.h:86
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:48
std::vector< uint8_t > public_value() const
Definition x448.h:44
std::array< uint8_t, 56 > m_public
Definition x448.h:54
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