Botan 3.11.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)
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
21namespace Botan {
22
23class FrodoKEM_PublicKeyInternal;
24class 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 */
33class 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
43
44 ~FrodoKEM_PublicKey() override = default;
45
46 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 bool supports_operation(PublicKeyOperation op) const override {
64 }
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 FrodoKEM_PublicKey() = default;
73
74 protected:
75 std::shared_ptr<FrodoKEM_PublicKeyInternal> m_public; // NOLINT(*-non-private-member-variable*)
76};
77
80
81class BOTAN_PUBLIC_API(3, 3) FrodoKEM_PrivateKey final : public virtual FrodoKEM_PublicKey,
82 public virtual Private_Key {
83 public:
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
93
95
96 std::unique_ptr<PK_Ops::KEM_Decryption> create_kem_decryption_op(RandomNumberGenerator& rng,
97 std::string_view params,
98 std::string_view provider) const override;
99
100 private:
101 std::shared_ptr<FrodoKEM_PrivateKeyInternal> m_private;
102};
103
105
106} // namespace Botan
107
108#endif
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:122
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:119
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:121
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
FrodoKEM_PrivateKey(RandomNumberGenerator &rng, FrodoKEMMode mode)
Definition frodokem.cpp:322
std::unique_ptr< PK_Ops::KEM_Decryption > create_kem_decryption_op(RandomNumberGenerator &rng, std::string_view params, std::string_view provider) const override
Definition frodokem.cpp:395
secure_vector< uint8_t > raw_private_key_bits() const override
Definition frodokem.cpp:387
secure_vector< uint8_t > private_key_bits() const override
Definition frodokem.cpp:383
std::unique_ptr< Public_Key > public_key() const override
Definition frodokem.cpp:379
~FrodoKEM_PublicKey() override=default
std::shared_ptr< FrodoKEM_PublicKeyInternal > m_public
Definition frodokem.h:75
FrodoKEM_PublicKey(std::span< const uint8_t > pub_key, FrodoKEMMode mode)
Definition frodokem.cpp:244
FrodoKEM_PublicKey & operator=(FrodoKEM_PublicKey &&)=default
FrodoKEM_PublicKey & operator=(const FrodoKEM_PublicKey &other)
Definition frodokem.cpp:268
std::string algo_name() const override
Definition frodokem.h:46
FrodoKEM_PublicKey(FrodoKEM_PublicKey &&)=default
bool supports_operation(PublicKeyOperation op) const override
Definition frodokem.h:62
PublicKeyOperation
Definition pk_keys.h:46
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:68