Coverage Report

Created: 2026-12-01 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Botan-3.13.0/build/include/public/botan/ed448.h
Line
Count
Source
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
17
namespace Botan {
18
19
class Ed448_PublicKey_Data;
20
class 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
 */
31
class BOTAN_PUBLIC_API(3, 4) Ed448_PublicKey : public virtual Public_Key {
32
   public:
33
0
      std::string algo_name() const override { return "Ed448"; }
34
35
0
      size_t estimated_strength() const override { return 224; }
36
37
0
      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
0
      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
0
      Ed448_PublicKey() = default;
71
      std::shared_ptr<const Ed448_PublicKey_Data> m_public;  // NOLINT(*non-private-member-variable*)
72
};
73
74
BOTAN_DIAGNOSTIC_PUSH
75
BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
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
 */
86
class BOTAN_PUBLIC_API(3, 4) Ed448_PrivateKey final : public Ed448_PublicKey,
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
      */
109
      explicit Ed448_PrivateKey(RandomNumberGenerator& rng);
110
111
      secure_vector<uint8_t> raw_private_key_bits() const override;
112
113
      secure_vector<uint8_t> private_key_bits() const override;
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
127
BOTAN_DIAGNOSTIC_POP
128
129
}  // namespace Botan
130
131
#endif