Botan 3.6.1
Crypto and TLS for C&
Botan::KyberMode Class Reference

#include <kyber.h>

Public Types

enum  Mode {
  Kyber512_R3 , Kyber768_R3 , Kyber1024_R3 , Kyber512 = Kyber512_R3 ,
  Kyber768 = Kyber768_R3 , Kyber1024 = Kyber1024_R3 , ML_KEM_512 , ML_KEM_768 ,
  ML_KEM_1024 , Kyber512_90s , Kyber768_90s , Kyber1024_90s
}
 

Public Member Functions

bool is_90s () const
 
bool is_available () const
 
bool is_kyber_round3 () const
 
bool is_ml_kem () const
 
bool is_modern () const
 
 KyberMode (const OID &oid)
 
 KyberMode (Mode mode)
 
 KyberMode (std::string_view str)
 
Mode mode () const
 
OID object_identifier () const
 
bool operator!= (const KyberMode &other) const
 
bool operator== (const KyberMode &other) const
 
std::string to_string () const
 

Detailed Description

Definition at line 32 of file kyber.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Kyber512_R3 
Kyber768_R3 
Kyber1024_R3 
Kyber512 
Kyber768 
Kyber1024 
ML_KEM_512 
ML_KEM_768 
ML_KEM_1024 
Kyber512_90s 
Kyber768_90s 
Kyber1024_90s 

Definition at line 34 of file kyber.h.

34 {
35 // Kyber512 as proposed in round 3 of the NIST competition
37 // Kyber768 as proposed in round 3 of the NIST competition
39 // Kyber1024 as proposed in round 3 of the NIST competition
41
42 Kyber512 BOTAN_DEPRECATED("Use Kyber512_R3") = Kyber512_R3,
43 Kyber768 BOTAN_DEPRECATED("Use Kyber768_R3") = Kyber768_R3,
44 Kyber1024 BOTAN_DEPRECATED("Use Kyber1024_R3") = Kyber1024_R3,
45
49
50 Kyber512_90s BOTAN_DEPRECATED("Kyber 90s mode is deprecated"),
51 Kyber768_90s BOTAN_DEPRECATED("Kyber 90s mode is deprecated"),
52 Kyber1024_90s BOTAN_DEPRECATED("Kyber 90s mode is deprecated"),
53 };
#define BOTAN_DEPRECATED(msg)
Definition compiler.h:125

Constructor & Destructor Documentation

◆ KyberMode() [1/3]

Botan::KyberMode::KyberMode ( Mode mode)

Definition at line 89 of file kyber.cpp.

89: m_mode(mode) {}
Mode mode() const
Definition kyber.h:62

◆ KyberMode() [2/3]

Botan::KyberMode::KyberMode ( const OID & oid)
explicit

Definition at line 91 of file kyber.cpp.

91: m_mode(kyber_mode_from_string(oid.to_formatted_string())) {}

◆ KyberMode() [3/3]

Botan::KyberMode::KyberMode ( std::string_view str)
explicit

Definition at line 93 of file kyber.cpp.

93: m_mode(kyber_mode_from_string(str)) {}

Member Function Documentation

◆ is_90s()

bool Botan::KyberMode::is_90s ( ) const

Definition at line 124 of file kyber.cpp.

124 {
125 return m_mode == Kyber512_90s || m_mode == Kyber768_90s || m_mode == Kyber1024_90s;
126}

References Kyber1024_90s, Kyber512_90s, and Kyber768_90s.

Referenced by is_available(), is_modern(), and Botan::KyberConstants::KyberConstants().

◆ is_available()

bool Botan::KyberMode::is_available ( ) const

Definition at line 141 of file kyber.cpp.

141 {
142#if defined(BOTAN_HAS_KYBER)
143 if(is_kyber_round3() && is_modern()) {
144 return true;
145 }
146#endif
147
148#if defined(BOTAN_HAS_KYBER_90S)
149 if(is_kyber_round3() && is_90s()) {
150 return true;
151 }
152#endif
153
154#if defined(BOTAN_HAS_ML_KEM)
155 if(is_ml_kem()) {
156 return true;
157 }
158#endif
159
160 return false;
161}
bool is_kyber_round3() const
Definition kyber.cpp:136
bool is_modern() const
Definition kyber.cpp:128
bool is_90s() const
Definition kyber.cpp:124
bool is_ml_kem() const
Definition kyber.cpp:132

References is_90s(), is_kyber_round3(), is_ml_kem(), and is_modern().

◆ is_kyber_round3()

bool Botan::KyberMode::is_kyber_round3 ( ) const

Definition at line 136 of file kyber.cpp.

136 {
137 return m_mode == KyberMode::Kyber512_R3 || m_mode == KyberMode::Kyber768_R3 || m_mode == KyberMode::Kyber1024_R3 ||
139}

References Kyber1024_90s, Kyber1024_R3, Kyber512_90s, Kyber512_R3, Kyber768_90s, and Kyber768_R3.

Referenced by is_available(), and Botan::KyberConstants::KyberConstants().

◆ is_ml_kem()

bool Botan::KyberMode::is_ml_kem ( ) const

Definition at line 132 of file kyber.cpp.

132 {
133 return m_mode == KyberMode::ML_KEM_512 || m_mode == KyberMode::ML_KEM_768 || m_mode == KyberMode::ML_KEM_1024;
134}

References ML_KEM_1024, ML_KEM_512, and ML_KEM_768.

Referenced by Botan::Kyber_PublicKey::algo_name(), is_available(), and Botan::KyberConstants::KyberConstants().

◆ is_modern()

bool Botan::KyberMode::is_modern ( ) const

Definition at line 128 of file kyber.cpp.

128 {
129 return !is_90s();
130}

References is_90s().

Referenced by is_available(), and Botan::KyberConstants::KyberConstants().

◆ mode()

Mode Botan::KyberMode::mode ( ) const
inline

Definition at line 62 of file kyber.h.

62{ return m_mode; }

Referenced by Botan::KyberConstants::KyberConstants(), and Botan::Kyber_PublicKey::mode().

◆ object_identifier()

OID Botan::KyberMode::object_identifier ( ) const

Definition at line 95 of file kyber.cpp.

95 {
97}
std::string to_string() const
Definition kyber.cpp:99
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:86

References Botan::OID::from_string(), and to_string().

Referenced by Botan::Kyber_PublicKey::object_identifier().

◆ operator!=()

bool Botan::KyberMode::operator!= ( const KyberMode & other) const
inline

Definition at line 76 of file kyber.h.

76{ return !(*this == other); }

◆ operator==()

bool Botan::KyberMode::operator== ( const KyberMode & other) const
inline

Definition at line 74 of file kyber.h.

74{ return m_mode == other.m_mode; }

◆ to_string()

std::string Botan::KyberMode::to_string ( ) const

Definition at line 99 of file kyber.cpp.

99 {
100 switch(m_mode) {
101 case Kyber512_90s:
102 return "Kyber-512-90s-r3";
103 case Kyber768_90s:
104 return "Kyber-768-90s-r3";
105 case Kyber1024_90s:
106 return "Kyber-1024-90s-r3";
107 case Kyber512_R3:
108 return "Kyber-512-r3";
109 case Kyber768_R3:
110 return "Kyber-768-r3";
111 case Kyber1024_R3:
112 return "Kyber-1024-r3";
113 case ML_KEM_512:
114 return "ML-KEM-512";
115 case ML_KEM_768:
116 return "ML-KEM-768";
117 case ML_KEM_1024:
118 return "ML-KEM-1024";
119 }
120
122}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137

References BOTAN_ASSERT_UNREACHABLE, Kyber1024_90s, Kyber1024_R3, Kyber512_90s, Kyber512_R3, Kyber768_90s, Kyber768_R3, ML_KEM_1024, ML_KEM_512, and ML_KEM_768.

Referenced by object_identifier().


The documentation for this class was generated from the following files: