Botan 3.13.0
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 21 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 23 of file dilithium.h.

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

Constructor & Destructor Documentation

◆ DilithiumMode() [1/3]

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

Definition at line 37 of file dilithium.h.

37: m_mode(mode) {}
Mode mode() const
Definition dilithium.h:53

References mode().

◆ DilithiumMode() [2/3]

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

Definition at line 74 of file dilithium.cpp.

74: m_mode(dilithium_mode_from_oid(oid)) {}

◆ DilithiumMode() [3/3]

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

Definition at line 76 of file dilithium.cpp.

76: m_mode(dilithium_mode_from_string(str)) {}

Member Function Documentation

◆ is_aes()

bool Botan::DilithiumMode::is_aes ( ) const

Definition at line 107 of file dilithium.cpp.

107 {
108 return m_mode == Dilithium4x4_AES || m_mode == Dilithium6x5_AES || m_mode == Dilithium8x7_AES;
109}

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 119 of file dilithium.cpp.

119 {
120#if defined(BOTAN_HAS_DILITHIUM_AES)
121 if(is_dilithium_round3() && is_aes()) {
122 return true;
123 }
124#endif
125#if defined(BOTAN_HAS_DILITHIUM)
126 if(is_dilithium_round3() && is_modern()) {
127 return true;
128 }
129#endif
130#if defined(BOTAN_HAS_ML_DSA)
131 if(is_ml_dsa()) {
132 return true;
133 }
134#endif
135 return false;
136}
bool is_aes() const
bool is_modern() const
bool is_dilithium_round3() const
Definition dilithium.h:49
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 49 of file dilithium.h.

49{ 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 115 of file dilithium.cpp.

115 {
116 return m_mode == ML_DSA_4x4 || m_mode == ML_DSA_6x5 || m_mode == ML_DSA_8x7;
117}

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 111 of file dilithium.cpp.

111 {
112 return !is_aes();
113}

References is_aes().

Referenced by is_available().

◆ mode()

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

Definition at line 53 of file dilithium.h.

53{ return m_mode; }

Referenced by DilithiumMode().

◆ object_identifier()

OID Botan::DilithiumMode::object_identifier ( ) const

Definition at line 78 of file dilithium.cpp.

78 {
80}
std::string to_string() const
Definition dilithium.cpp:82
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 82 of file dilithium.cpp.

82 {
83 switch(m_mode) {
85 return "Dilithium-4x4-r3";
87 return "Dilithium-4x4-AES-r3";
89 return "Dilithium-6x5-r3";
91 return "Dilithium-6x5-AES-r3";
93 return "Dilithium-8x7-r3";
95 return "Dilithium-8x7-AES-r3";
97 return "ML-DSA-4x4";
99 return "ML-DSA-6x5";
101 return "ML-DSA-8x7";
102 }
103
105}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:166

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: