Botan 3.5.0
Crypto and TLS for C&
frodo_mode.h
Go to the documentation of this file.
1/*
2 * FrodoKEM modes and constants
3 *
4 * The Fellowship of the FrodoKEM:
5 * (C) 2023 Jack Lloyd
6 * 2023 René Meusel, Amos Treiber - Rohde & Schwarz Cybersecurity
7 *
8 * Botan is released under the Simplified BSD License (see license.txt)
9 */
10
11#ifndef BOTAN_FRODOKEM_MODE_H_
12#define BOTAN_FRODOKEM_MODE_H_
13
14#include <botan/asn1_obj.h>
15
16#include <vector>
17
18namespace Botan {
19
21 public:
36
37 FrodoKEMMode(Mode mode);
38 explicit FrodoKEMMode(const OID& oid);
39 explicit FrodoKEMMode(std::string_view str);
40
41 OID object_identifier() const;
42 std::string to_string() const;
43
44 Mode mode() const { return m_mode; }
45
46 bool is_ephemeral() const {
47 return m_mode == eFrodoKEM640_SHAKE || m_mode == eFrodoKEM976_SHAKE || m_mode == eFrodoKEM1344_SHAKE ||
48 m_mode == eFrodoKEM640_AES || m_mode == eFrodoKEM976_AES || m_mode == eFrodoKEM1344_AES;
49 }
50
51 bool is_static() const {
52 return m_mode == FrodoKEM640_SHAKE || m_mode == FrodoKEM976_SHAKE || m_mode == FrodoKEM1344_SHAKE ||
53 m_mode == FrodoKEM640_AES || m_mode == FrodoKEM976_AES || m_mode == FrodoKEM1344_AES;
54 }
55
56 bool is_shake() const {
57 return m_mode == eFrodoKEM640_SHAKE || m_mode == eFrodoKEM976_SHAKE || m_mode == eFrodoKEM1344_SHAKE ||
58 m_mode == FrodoKEM640_SHAKE || m_mode == FrodoKEM976_SHAKE || m_mode == FrodoKEM1344_SHAKE;
59 }
60
61 bool is_aes() const {
62 return m_mode == eFrodoKEM640_AES || m_mode == eFrodoKEM976_AES || m_mode == eFrodoKEM1344_AES ||
63 m_mode == FrodoKEM640_AES || m_mode == FrodoKEM976_AES || m_mode == FrodoKEM1344_AES;
64 }
65
66 bool is_available() const {
67 return
68#if defined(BOTAN_HAS_FRODOKEM_AES)
69 is_aes() ||
70#endif
71
72#if defined(BOTAN_HAS_FRODOKEM_SHAKE)
73 is_shake() ||
74#endif
75
76 false;
77 }
78
79 bool operator==(const FrodoKEMMode& other) const { return m_mode == other.m_mode; }
80
81 bool operator!=(const FrodoKEMMode& other) const { return !(*this == other); }
82
83 private:
84 Mode m_mode;
85};
86
87} // namespace Botan
88
89#endif
bool is_static() const
Definition frodo_mode.h:51
bool is_aes() const
Definition frodo_mode.h:61
bool is_available() const
Definition frodo_mode.h:66
Mode mode() const
Definition frodo_mode.h:44
bool is_ephemeral() const
Definition frodo_mode.h:46
bool operator==(const FrodoKEMMode &other) const
Definition frodo_mode.h:79
bool is_shake() const
Definition frodo_mode.h:56
bool operator!=(const FrodoKEMMode &other) const
Definition frodo_mode.h:81
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31