/src/botan/build/include/public/botan/frodokem.h
Line | Count | Source |
1 | | /* |
2 | | * FrodoKEM implementation |
3 | | * Based on the MIT licensed reference implementation by the designers |
4 | | * (https://github.com/microsoft/PQCrypto-LWEKE/tree/master) |
5 | | * |
6 | | * The Fellowship of the FrodoKEM: |
7 | | * (C) 2023 Jack Lloyd |
8 | | * 2023 René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity |
9 | | * |
10 | | * Botan is released under the Simplified BSD License (see license.txt) |
11 | | */ |
12 | | |
13 | | #ifndef BOTAN_FRODOKEM_H_ |
14 | | #define BOTAN_FRODOKEM_H_ |
15 | | |
16 | | #include <botan/frodo_mode.h> |
17 | | #include <botan/pk_keys.h> |
18 | | |
19 | | #include <vector> |
20 | | |
21 | | namespace Botan { |
22 | | |
23 | | class FrodoKEM_PublicKeyInternal; |
24 | | class FrodoKEM_PrivateKeyInternal; |
25 | | |
26 | | /** |
27 | | * FrodoKEM is an unstructured lattice-based post-quantum secure KEM. It is a |
28 | | * round 3 candidate in NIST's PQC competition but was eventually not considered |
29 | | * for standardization by NIST. Nevertheless, it is endorsed by the German |
30 | | * Federal Office for Information Security for its conservative security |
31 | | * assumptions and is being standardized as an ISO standard. |
32 | | */ |
33 | | class BOTAN_PUBLIC_API(3, 3) FrodoKEM_PublicKey : public virtual Public_Key { |
34 | | public: |
35 | | FrodoKEM_PublicKey(std::span<const uint8_t> pub_key, FrodoKEMMode mode); |
36 | | |
37 | | FrodoKEM_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits); |
38 | | |
39 | | FrodoKEM_PublicKey(const FrodoKEM_PublicKey& other); |
40 | | FrodoKEM_PublicKey& operator=(const FrodoKEM_PublicKey& other); |
41 | | FrodoKEM_PublicKey(FrodoKEM_PublicKey&&) = default; |
42 | | FrodoKEM_PublicKey& operator=(FrodoKEM_PublicKey&&) = default; |
43 | | |
44 | 0 | ~FrodoKEM_PublicKey() override = default; |
45 | | |
46 | 0 | std::string algo_name() const override { return "FrodoKEM"; } |
47 | | |
48 | | AlgorithmIdentifier algorithm_identifier() const override; |
49 | | |
50 | | OID object_identifier() const override; |
51 | | |
52 | | size_t key_length() const override; |
53 | | |
54 | | size_t estimated_strength() const override; |
55 | | |
56 | | std::vector<uint8_t> raw_public_key_bits() const override; |
57 | | |
58 | | std::vector<uint8_t> public_key_bits() const override; |
59 | | |
60 | | bool check_key(RandomNumberGenerator& rng, bool strong) const override; |
61 | | |
62 | 0 | bool supports_operation(PublicKeyOperation op) const override { |
63 | 0 | return (op == PublicKeyOperation::KeyEncapsulation); |
64 | 0 | } |
65 | | |
66 | | std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final; |
67 | | |
68 | | std::unique_ptr<PK_Ops::KEM_Encryption> create_kem_encryption_op(std::string_view params, |
69 | | std::string_view provider) const override; |
70 | | |
71 | | protected: |
72 | 0 | FrodoKEM_PublicKey() = default; |
73 | | |
74 | | protected: |
75 | | std::shared_ptr<const FrodoKEM_PublicKeyInternal> m_public; // NOLINT(*-non-private-member-variable*) |
76 | | }; |
77 | | |
78 | | BOTAN_DIAGNOSTIC_PUSH |
79 | | BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE |
80 | | |
81 | | class BOTAN_PUBLIC_API(3, 3) FrodoKEM_PrivateKey final : public virtual FrodoKEM_PublicKey, |
82 | | public virtual Private_Key { |
83 | | public: |
84 | | FrodoKEM_PrivateKey(RandomNumberGenerator& rng, FrodoKEMMode mode); |
85 | | |
86 | | FrodoKEM_PrivateKey(std::span<const uint8_t> sk, FrodoKEMMode mode); |
87 | | |
88 | | FrodoKEM_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits); |
89 | | |
90 | | std::unique_ptr<Public_Key> public_key() const override; |
91 | | |
92 | | bool check_key(RandomNumberGenerator& rng, bool strong) const override; |
93 | | |
94 | | secure_vector<uint8_t> private_key_bits() const override; |
95 | | |
96 | | secure_vector<uint8_t> raw_private_key_bits() const override; |
97 | | |
98 | | std::unique_ptr<PK_Ops::KEM_Decryption> create_kem_decryption_op(RandomNumberGenerator& rng, |
99 | | std::string_view params, |
100 | | std::string_view provider) const override; |
101 | | |
102 | | private: |
103 | | std::shared_ptr<const FrodoKEM_PrivateKeyInternal> m_private; |
104 | | }; |
105 | | |
106 | | BOTAN_DIAGNOSTIC_POP |
107 | | |
108 | | } // namespace Botan |
109 | | |
110 | | #endif |