Botan 3.14.1
Crypto and TLS for C&
Botan::DilithiumMode Class Referencefinal

#include <dilithium.h>

Public Types

enum  Mode : uint8_t {
  Dilithium4x4 = 1 , Dilithium4x4_AES , Dilithium6x5 , Dilithium6x5_AES ,
  Dilithium8x7 , Dilithium8x7_AES , ML_DSA_4x4 , ML_DSA_6x5 ,
  ML_DSA_8x7
}

Public Member Functions

 DilithiumMode (const OID &oid)
 DilithiumMode (Mode mode)
 DilithiumMode (std::string_view str)
bool is_aes () const
bool is_available () const
bool is_dilithium_round3 () const
bool is_ml_dsa () const
bool is_modern () const
Mode mode () const
OID object_identifier () const
std::string to_string () const

Detailed Description

Definition at line 22 of file dilithium.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Dilithium4x4 
Dilithium4x4_AES 
Dilithium6x5 
Dilithium6x5_AES 
Dilithium8x7 
Dilithium8x7_AES 
ML_DSA_4x4 
ML_DSA_6x5 
ML_DSA_8x7 

Definition at line 24 of file dilithium.h.

24 : uint8_t /* NOLINT(*-use-enum-class) */ {
25 Dilithium4x4 BOTAN_DEPRECATED("Dilithium R3 is deprecated - use ML-DSA") = 1,
26 Dilithium4x4_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
27 Dilithium6x5 BOTAN_DEPRECATED("Dilithium R3 is deprecated - use ML-DSA"),
28 Dilithium6x5_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
29 Dilithium8x7 BOTAN_DEPRECATED("Dilithium R3 is deprecated - use ML-DSA"),
30 Dilithium8x7_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
34 };
#define BOTAN_DEPRECATED(msg)
Definition api.h:73

Constructor & Destructor Documentation

◆ DilithiumMode() [1/3]

Botan::DilithiumMode::DilithiumMode ( Mode mode)
inline

Definition at line 38 of file dilithium.h.

38: m_mode(mode) {}
Mode mode() const
Definition dilithium.h:54

References mode().

◆ DilithiumMode() [2/3]

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

Definition at line 78 of file dilithium.cpp.

78: m_mode(dilithium_mode_from_oid(oid)) {}

◆ DilithiumMode() [3/3]

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

Definition at line 80 of file dilithium.cpp.

80: m_mode(dilithium_mode_from_string(str)) {}

Member Function Documentation

◆ is_aes()

bool Botan::DilithiumMode::is_aes ( ) const

Definition at line 111 of file dilithium.cpp.

111 {
112 return m_mode == Dilithium4x4_AES || m_mode == Dilithium6x5_AES || m_mode == Dilithium8x7_AES;
113}

References Dilithium4x4_AES, Dilithium6x5_AES, and Dilithium8x7_AES.

Referenced by is_available(), and is_modern().

◆ is_available()

bool Botan::DilithiumMode::is_available ( ) const

Definition at line 123 of file dilithium.cpp.

123 {
124#if defined(BOTAN_HAS_DILITHIUM_AES)
125 if(is_dilithium_round3() && is_aes()) {
126 return true;
127 }
128#endif
129#if defined(BOTAN_HAS_DILITHIUM)
130 if(is_dilithium_round3() && is_modern()) {
131 return true;
132 }
133#endif
134#if defined(BOTAN_HAS_ML_DSA)
135 if(is_ml_dsa()) {
136 return true;
137 }
138#endif
139 return false;
140}
bool is_aes() const
bool is_modern() const
bool is_dilithium_round3() const
Definition dilithium.h:50
bool is_ml_dsa() const

References is_aes(), is_dilithium_round3(), is_ml_dsa(), and is_modern().

Referenced by Botan::Dilithium_Expanded_Keypair_Codec::decode_keypair(), Botan::Dilithium_PrivateKey::Dilithium_PrivateKey(), and Botan::Dilithium_PublicKey::Dilithium_PublicKey().

◆ is_dilithium_round3()

bool Botan::DilithiumMode::is_dilithium_round3 ( ) const
inline

Definition at line 50 of file dilithium.h.

50{ return !is_ml_dsa(); }

References is_dilithium_round3(), and is_ml_dsa().

Referenced by Botan::Dilithium_Keypair_Codec::create(), is_available(), and is_dilithium_round3().

◆ is_ml_dsa()

bool Botan::DilithiumMode::is_ml_dsa ( ) const

Definition at line 119 of file dilithium.cpp.

119 {
120 return m_mode == ML_DSA_4x4 || m_mode == ML_DSA_6x5 || m_mode == ML_DSA_8x7;
121}

References ML_DSA_4x4, ML_DSA_6x5, and ML_DSA_8x7.

Referenced by Botan::Dilithium_Keypair_Codec::create(), is_available(), and is_dilithium_round3().

◆ is_modern()

bool Botan::DilithiumMode::is_modern ( ) const

Definition at line 115 of file dilithium.cpp.

115 {
116 return !is_aes();
117}

References is_aes().

Referenced by is_available().

◆ mode()

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

Definition at line 54 of file dilithium.h.

54{ return m_mode; }

Referenced by DilithiumMode().

◆ object_identifier()

OID Botan::DilithiumMode::object_identifier ( ) const

Definition at line 82 of file dilithium.cpp.

82 {
84}
std::string to_string() const
Definition dilithium.cpp:86
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:80

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

◆ to_string()

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

Definition at line 86 of file dilithium.cpp.

86 {
87 switch(m_mode) {
89 return "Dilithium-4x4-r3";
91 return "Dilithium-4x4-AES-r3";
93 return "Dilithium-6x5-r3";
95 return "Dilithium-6x5-AES-r3";
97 return "Dilithium-8x7-r3";
99 return "Dilithium-8x7-AES-r3";
101 return "ML-DSA-4x4";
103 return "ML-DSA-6x5";
105 return "ML-DSA-8x7";
106 }
107
109}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:173

References BOTAN_ASSERT_UNREACHABLE, Dilithium4x4, Dilithium4x4_AES, Dilithium6x5, Dilithium6x5_AES, Dilithium8x7, Dilithium8x7_AES, ML_DSA_4x4, ML_DSA_6x5, and ML_DSA_8x7.

Referenced by object_identifier().


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