Botan 3.13.0
Crypto and TLS for C&
ed448.h
Go to the documentation of this file.
1/*
2 * Ed448 Signature Algorithm (RFC 8032)
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
9#ifndef BOTAN_ED448_H_
10#define BOTAN_ED448_H_
11
12#include <botan/pk_keys.h>
13
14#include <memory>
15#include <vector>
16
17namespace Botan {
18
19class Ed448_PublicKey_Data;
20class Ed448_PrivateKey_Data;
21
22/**
23 * @brief A public key for Ed448/Ed448ph according to RFC 8032.
24 *
25 * By default, Ed448 without prehash is used (recommended). To use
26 * Ed448ph, "Ed448ph" or a custom hash function identifier is passed
27 * as a parameter to the create_verification_op method.
28 *
29 * Note that contexts (i.e. Ed448ctx) are not supported by this interface.
30 */
31class BOTAN_PUBLIC_API(3, 4) Ed448_PublicKey : public virtual Public_Key {
32 public:
33 std::string algo_name() const override { return "Ed448"; }
34
35 size_t estimated_strength() const override { return 224; }
36
37 size_t key_length() const override { return 448; }
38
39 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
40
41 AlgorithmIdentifier algorithm_identifier() const override;
42
43 std::vector<uint8_t> raw_public_key_bits() const override;
44
45 std::vector<uint8_t> public_key_bits() const override;
46
47 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
48
49 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
50
51 /**
52 * Create a Ed448 Public Key.
53 * @param alg_id the X.509 algorithm identifier
54 * @param key_bits DER encoded public key bits
55 */
56 Ed448_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
57
58 /**
59 * Create a Ed448 Public Key from bytes (57 Bytes).
60 */
61 BOTAN_FUTURE_EXPLICIT Ed448_PublicKey(std::span<const uint8_t> key_bits);
62
63 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
64 std::string_view provider) const override;
65
66 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
67 std::string_view provider) const override;
68
69 protected:
70 Ed448_PublicKey() = default;
71 std::shared_ptr<const Ed448_PublicKey_Data> m_public; // NOLINT(*non-private-member-variable*)
72};
73
76
77/**
78 * @brief A private key for Ed448/Ed448ph according to RFC 8032.
79 *
80 * By default, Ed448 without prehash is used (recommended). To use
81 * Ed448ph, "Ed448ph" or a custom hash function identifier is passed
82 * as a parameter to the create_verification_op method.
83 *
84 * Note that contexts (i.e. Ed448ctx) are not supported by this interface.
85 */
87 public virtual Private_Key {
88 public:
89 /**
90 * Construct a private key from the specified parameters.
91 *
92 * @param alg_id the X.509 algorithm identifier
93 * @param key_bits PKCS #8 structure
94 */
95 Ed448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
96
97 /**
98 * Construct a private key from bytes.
99 *
100 * @param key_bits private key bytes (57 Bytes)
101 */
102 BOTAN_FUTURE_EXPLICIT Ed448_PrivateKey(std::span<const uint8_t> key_bits);
103
104 /**
105 * Generate a new private key.
106 *
107 * @param rng the RNG to use
108 */
110
112
114
115 std::unique_ptr<Public_Key> public_key() const override;
116
117 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
118
119 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
120 std::string_view params,
121 std::string_view provider) const override;
122
123 private:
124 std::shared_ptr<const Ed448_PrivateKey_Data> m_private;
125};
126
128
129} // namespace Botan
130
131#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_FUTURE_EXPLICIT
Definition api.h:52
Ed448_PrivateKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition ed448.cpp:91
std::unique_ptr< PK_Ops::Signature > create_signature_op(RandomNumberGenerator &rng, std::string_view params, std::string_view provider) const override
Definition ed448.cpp:295
bool check_key(RandomNumberGenerator &rng, bool strong) const override
Definition ed448.cpp:135
secure_vector< uint8_t > raw_private_key_bits() const override
Definition ed448.cpp:43
secure_vector< uint8_t > private_key_bits() const override
Definition ed448.cpp:129
std::unique_ptr< Public_Key > public_key() const override
Definition ed448.cpp:125
A public key for Ed448/Ed448ph according to RFC 8032.
Definition ed448.h:31
std::string algo_name() const override
Definition ed448.h:33
bool supports_operation(PublicKeyOperation op) const override
Definition ed448.h:49
std::shared_ptr< const Ed448_PublicKey_Data > m_public
Definition ed448.h:71
Ed448_PublicKey(const AlgorithmIdentifier &alg_id, std::span< const uint8_t > key_bits)
Definition ed448.cpp:61
size_t key_length() const override
Definition ed448.h:37
size_t estimated_strength() const override
Definition ed448.h:35
PublicKeyOperation
Definition pk_keys.h:46
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128