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