Coverage Report

Created: 2026-07-16 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/botan/build/include/public/botan/x448.h
Line
Count
Source
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 <memory>
14
#include <vector>
15
16
namespace Botan {
17
18
class X448_PublicKey_Data;
19
class X448_PrivateKey_Data;
20
21
/**
22
 * @brief A public key for the X448 key agreement scheme according to RFC 7748.
23
 */
24
class BOTAN_PUBLIC_API(3, 4) X448_PublicKey : public virtual Public_Key {
25
   public:
26
      /**
27
      * Create a X448 Public Key.
28
      * @param alg_id the X.509 algorithm identifier
29
      * @param key_bits DER encoded public key bits
30
      */
31
      X448_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
32
33
      /**
34
      * Create a X448 Public Key.
35
      * @param pub 56-byte raw public key
36
      */
37
      explicit X448_PublicKey(std::span<const uint8_t> pub);
38
39
7
      std::string algo_name() const override { return "X448"; }
40
41
0
      size_t estimated_strength() const override { return 224; }
42
43
2
      size_t key_length() const override { return 448; }
44
45
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
46
47
      AlgorithmIdentifier algorithm_identifier() const override;
48
49
0
      BOTAN_DEPRECATED("Use raw_public_key_bits") std::vector<uint8_t> public_value() const {
50
0
         return raw_public_key_bits();
51
0
      }
52
53
      std::vector<uint8_t> raw_public_key_bits() const override;
54
55
      std::vector<uint8_t> public_key_bits() const override;
56
57
0
      bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::KeyAgreement); }
58
59
      std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
60
61
   protected:
62
13
      X448_PublicKey() = default;
63
      std::shared_ptr<const X448_PublicKey_Data> m_public;  // NOLINT(*non-private-member-variable*)
64
};
65
66
BOTAN_DIAGNOSTIC_PUSH
67
BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
68
69
/**
70
 * @brief A private key for the X448 key agreement scheme according to RFC 7748.
71
 */
72
class BOTAN_PUBLIC_API(3, 4) X448_PrivateKey final : public X448_PublicKey,
73
                                                     public virtual Private_Key,
74
                                                     public virtual PK_Key_Agreement_Key {
75
   public:
76
      /**
77
      * Construct a private key from the specified parameters.
78
      * @param alg_id the X.509 algorithm identifier
79
      * @param key_bits PKCS #8 structure
80
      */
81
      X448_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
82
83
      /**
84
      * Generate a private key.
85
      * @param rng the RNG to use
86
      */
87
      explicit X448_PrivateKey(RandomNumberGenerator& rng);
88
89
      /**
90
      * Construct a private key from the specified parameters.
91
      * @param secret_key the private key
92
      */
93
      explicit X448_PrivateKey(std::span<const uint8_t> secret_key);
94
95
0
      std::vector<uint8_t> public_value() const override { return raw_public_key_bits(); }
96
97
      secure_vector<uint8_t> raw_private_key_bits() const override;
98
99
      secure_vector<uint8_t> private_key_bits() const override;
100
101
      std::unique_ptr<Public_Key> public_key() const override;
102
103
      bool check_key(RandomNumberGenerator& rng, bool strong) const override;
104
105
      std::unique_ptr<PK_Ops::Key_Agreement> create_key_agreement_op(RandomNumberGenerator& rng,
106
                                                                     std::string_view params,
107
                                                                     std::string_view provider) const override;
108
109
   private:
110
      std::shared_ptr<const X448_PrivateKey_Data> m_private;
111
};
112
113
BOTAN_DIAGNOSTIC_POP
114
115
}  // namespace Botan
116
117
#endif