Botan 3.4.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 <array>
15
16namespace Botan {
17
18/**
19 * @brief A public key for Ed448/Ed448ph according to RFC 8032.
20 *
21 * By default, Ed448 without prehash is used (recommended). To use
22 * Ed448ph, "Ed448ph" or a custom hash function identifier is passed
23 * as a parameter to the create_verification_op method.
24 *
25 * Note that contexts (i.e. Ed448ctx) are not supported by this interface.
26 */
27class BOTAN_PUBLIC_API(3, 4) Ed448_PublicKey : public virtual Public_Key {
28 public:
29 std::string algo_name() const override { return "Ed448"; }
30
31 size_t estimated_strength() const override { return 224; }
32
33 size_t key_length() const override { return 448; }
34
35 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
36
37 AlgorithmIdentifier algorithm_identifier() const override;
38
39 std::vector<uint8_t> public_key_bits() const override;
40
41 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
42
43 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::Signature); }
44
45 /**
46 * Create a Ed448 Public Key.
47 * @param alg_id the X.509 algorithm identifier
48 * @param key_bits DER encoded public key bits
49 */
50 Ed448_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
51
52 /**
53 * Create a Ed448 Public Key from bytes (57 Bytes).
54 */
55 Ed448_PublicKey(std::span<const uint8_t> key_bits);
56
57 std::unique_ptr<PK_Ops::Verification> create_verification_op(std::string_view params,
58 std::string_view provider) const override;
59
60 std::unique_ptr<PK_Ops::Verification> create_x509_verification_op(const AlgorithmIdentifier& signature_algorithm,
61 std::string_view provider) const override;
62
63 protected:
64 Ed448_PublicKey() = default;
65 std::array<uint8_t, 57> m_public;
66};
67
70
71/**
72 * @brief A private key for Ed448/Ed448ph according to RFC 8032.
73 *
74 * By default, Ed448 without prehash is used (recommended). To use
75 * Ed448ph, "Ed448ph" or a custom hash function identifier is passed
76 * as a parameter to the create_verification_op method.
77 *
78 * Note that contexts (i.e. Ed448ctx) are not supported by this interface.
79 */
81 public virtual Private_Key {
82 public:
83 /**
84 * Construct a private key from the specified parameters.
85 *
86 * @param alg_id the X.509 algorithm identifier
87 * @param key_bits PKCS #8 structure
88 */
89 Ed448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
90
91 /**
92 * Construct a private key from bytes.
93 *
94 * @param key_bits private key bytes (57 Bytes)
95 */
96 Ed448_PrivateKey(std::span<const uint8_t> key_bits);
97
98 /**
99 * Generate a new private key.
100 *
101 * @param rng the RNG to use
102 */
104
105 secure_vector<uint8_t> raw_private_key_bits() const override { return {m_private.begin(), m_private.end()}; }
106
107 secure_vector<uint8_t> private_key_bits() const override;
108
109 std::unique_ptr<Public_Key> public_key() const override;
110
111 bool check_key(RandomNumberGenerator& rng, bool strong) const override;
112
113 std::unique_ptr<PK_Ops::Signature> create_signature_op(RandomNumberGenerator& rng,
114 std::string_view params,
115 std::string_view provider) const override;
116
117 private:
118 secure_vector<uint8_t> m_private;
119};
120
122
123} // namespace Botan
124
125#endif
A private key for Ed448/Ed448ph according to RFC 8032.
Definition ed448.h:81
secure_vector< uint8_t > raw_private_key_bits() const override
Definition ed448.h:105
A public key for Ed448/Ed448ph according to RFC 8032.
Definition ed448.h:27
std::array< uint8_t, 57 > m_public
Definition ed448.h:65
std::string algo_name() const override
Definition ed448.h:29
bool supports_operation(PublicKeyOperation op) const override
Definition ed448.h:43
size_t key_length() const override
Definition ed448.h:33
size_t estimated_strength() const override
Definition ed448.h:31
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