Botan 3.5.0
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 , Kyber512_90s , Kyber768_90s ,
  Kyber1024_90s
}
 

Public Member Functions

bool is_90s () const
 
bool is_available () const
 
bool is_kyber_round3 () 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 30 of file kyber.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Kyber512_R3 
Kyber768_R3 
Kyber1024_R3 
Kyber512 
Kyber768 
Kyber1024 
Kyber512_90s 
Kyber768_90s 
Kyber1024_90s 

Definition at line 32 of file kyber.h.

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

Constructor & Destructor Documentation

◆ KyberMode() [1/3]

Botan::KyberMode::KyberMode ( Mode mode)

Definition at line 75 of file kyber.cpp.

75: m_mode(mode) {}
Mode mode() const
Definition kyber.h:56

◆ KyberMode() [2/3]

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

Definition at line 77 of file kyber.cpp.

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

◆ KyberMode() [3/3]

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

Definition at line 79 of file kyber.cpp.

79: m_mode(kyber_mode_from_string(str)) {}

Member Function Documentation

◆ is_90s()

bool Botan::KyberMode::is_90s ( ) const

Definition at line 104 of file kyber.cpp.

104 {
105 return m_mode == Kyber512_90s || m_mode == Kyber768_90s || m_mode == Kyber1024_90s;
106}

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 117 of file kyber.cpp.

117 {
118#if defined(BOTAN_HAS_KYBER)
119 if(is_kyber_round3() && is_modern()) {
120 return true;
121 }
122#endif
123
124#if defined(BOTAN_HAS_KYBER_90S)
125 if(is_kyber_round3() && is_90s()) {
126 return true;
127 }
128#endif
129
130 return false;
131}
bool is_kyber_round3() const
Definition kyber.cpp:112
bool is_modern() const
Definition kyber.cpp:108
bool is_90s() const
Definition kyber.cpp:104

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

◆ is_kyber_round3()

bool Botan::KyberMode::is_kyber_round3 ( ) const

Definition at line 112 of file kyber.cpp.

112 {
113 return m_mode == KyberMode::Kyber512_R3 || m_mode == KyberMode::Kyber768_R3 || m_mode == KyberMode::Kyber1024_R3 ||
115}

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

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

◆ is_modern()

bool Botan::KyberMode::is_modern ( ) const

Definition at line 108 of file kyber.cpp.

108 {
109 return !is_90s();
110}

References is_90s().

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

◆ mode()

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

Definition at line 56 of file kyber.h.

56{ return m_mode; }

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

◆ object_identifier()

OID Botan::KyberMode::object_identifier ( ) const

Definition at line 81 of file kyber.cpp.

81 {
83}
std::string to_string() const
Definition kyber.cpp:85
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 68 of file kyber.h.

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

◆ operator==()

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

Definition at line 66 of file kyber.h.

66{ return m_mode == other.m_mode; }

◆ to_string()

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

Definition at line 85 of file kyber.cpp.

85 {
86 switch(m_mode) {
87 case Kyber512_90s:
88 return "Kyber-512-90s-r3";
89 case Kyber768_90s:
90 return "Kyber-768-90s-r3";
91 case Kyber1024_90s:
92 return "Kyber-1024-90s-r3";
93 case Kyber512_R3:
94 return "Kyber-512-r3";
95 case Kyber768_R3:
96 return "Kyber-768-r3";
97 case Kyber1024_R3:
98 return "Kyber-1024-r3";
99 }
100
102}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137

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

Referenced by object_identifier().


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