Botan 3.6.1
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> raw_public_key_bits() const override;
58
59 std::vector<uint8_t> public_key_bits() const override;
60
61 bool check_key(RandomNumberGenerator&, bool) const override;
62
63 bool supports_operation(PublicKeyOperation op) const override {
64 return (op == PublicKeyOperation::KeyEncapsulation);
65 }
66
67 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const final;
68
69 std::unique_ptr<PK_Ops::KEM_Encryption> create_kem_encryption_op(std::string_view params,
70 std::string_view provider) const override;
71
72 protected:
73 FrodoKEM_PublicKey() = default;
74
75 protected:
76 std::shared_ptr<FrodoKEM_PublicKeyInternal> m_public; // NOLINT(misc-non-private-member-variables-in-classes)
77};
78
81
83 public virtual Private_Key {
84 public:
86
87 FrodoKEM_PrivateKey(std::span<const uint8_t> sk, FrodoKEMMode mode);
88
89 FrodoKEM_PrivateKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);
90
91 std::unique_ptr<Public_Key> public_key() const override;
92
93 secure_vector<uint8_t> private_key_bits() const override;
94
95 secure_vector<uint8_t> raw_private_key_bits() const override;
96
97 std::unique_ptr<PK_Ops::KEM_Decryption> create_kem_decryption_op(RandomNumberGenerator& rng,
98 std::string_view params,
99 std::string_view provider) const override;
100
101 private:
102 std::shared_ptr<FrodoKEM_PrivateKeyInternal> m_private;
103};
104
106
107} // namespace Botan
108
109#endif
~FrodoKEM_PublicKey() override=default
std::shared_ptr< FrodoKEM_PublicKeyInternal > m_public
Definition frodokem.h:76
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:63
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