Botan 3.4.0
Crypto and TLS for C&
frodokem.h
Go to the documentation of this file.
1/*
2 * FrodoKEM implementation
3 * Based on the MIT licensed reference implementation by the designers
4 * (https://github.com/microsoft/PQCrypto-LWEKE/tree/master/src)
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 <tuple>
20#include <vector>
21
22namespace Botan {
23
24class FrodoKEM_PublicKeyInternal;
25class FrodoKEM_PrivateKeyInternal;
26
27/**
28 * FrodoKEM is an unstructured lattice-based post-quantum secure KEM. It is a
29 * round 3 candidate in NIST's PQC competition but was eventually not considered
30 * for standardization by NIST. Nevertheless, it is endorsed by the German
31 * Federal Office for Information Security for its conservative security
32 * assumptions and is being standardized as an ISO standard.
33 */
34class BOTAN_PUBLIC_API(3, 3) FrodoKEM_PublicKey : public virtual Public_Key {
35 public:
36 FrodoKEM_PublicKey(std::span<const uint8_t> pub_key, FrodoKEMMode mode);
37
38 FrodoKEM_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
39
41 FrodoKEM_PublicKey& operator=(const FrodoKEM_PublicKey& other);
44
45 ~FrodoKEM_PublicKey() override = default;
46
47 std::string algo_name() const override { return "FrodoKEM"; }
48
49 AlgorithmIdentifier algorithm_identifier() const override;
50
51 OID object_identifier() const override;
52
53 size_t key_length() const override;
54
55 size_t estimated_strength() const override;
56
57 std::vector<uint8_t> public_key_bits() const override;
58
59 bool check_key(RandomNumberGenerator&, bool) const override;
60
61 bool supports_operation(PublicKeyOperation op) const override {
62 return (op == PublicKeyOperation::KeyEncapsulation);
63 }
64
65 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
66
67 std::unique_ptr<PK_Ops::KEM_Encryption> create_kem_encryption_op(std::string_view params,
68 std::string_view provider) const override;
69
70 protected:
71 FrodoKEM_PublicKey() = default;
72
73 protected:
74 std::shared_ptr<FrodoKEM_PublicKeyInternal> m_public; // NOLINT(misc-non-private-member-variables-in-classes)
75};
76
79
81 public virtual Private_Key {
82 public:
84
85 FrodoKEM_PrivateKey(std::span<const uint8_t> sk, FrodoKEMMode mode);
86
87 FrodoKEM_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
88
89 std::unique_ptr<Public_Key> public_key() const override;
90
91 secure_vector<uint8_t> private_key_bits() const override;
92
93 secure_vector<uint8_t> raw_private_key_bits() const override;
94
95 std::unique_ptr<PK_Ops::KEM_Decryption> create_kem_decryption_op(RandomNumberGenerator& rng,
96 std::string_view params,
97 std::string_view provider) const override;
98
99 private:
100 std::shared_ptr<FrodoKEM_PrivateKeyInternal> m_private;
101};
102
104
105} // namespace Botan
106
107#endif
~FrodoKEM_PublicKey() override=default
std::shared_ptr< FrodoKEM_PublicKeyInternal > m_public
Definition frodokem.h:74
FrodoKEM_PublicKey & operator=(FrodoKEM_PublicKey &&)=default
std::string algo_name() const override
Definition frodokem.h:47
FrodoKEM_PublicKey(FrodoKEM_PublicKey &&)=default
bool supports_operation(PublicKeyOperation op) const override
Definition frodokem.h:61
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