Botan 3.6.0
Crypto and TLS for C&
Botan::DilithiumMode Class Reference

#include <dilithium.h>

Public Types

enum  Mode {
  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 {
24 Dilithium4x4 = 1,
25 Dilithium4x4_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
27 Dilithium6x5_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
29 Dilithium8x7_AES BOTAN_DEPRECATED("Dilithium AES mode is deprecated"),
33 };
#define BOTAN_DEPRECATED(msg)
Definition compiler.h:125

Constructor & Destructor Documentation

◆ DilithiumMode() [1/3]

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

Definition at line 36 of file dilithium.h.

36: m_mode(mode) {}
Mode mode() const
Definition dilithium.h:52

◆ DilithiumMode() [2/3]

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

Definition at line 65 of file dilithium.cpp.

65: m_mode(dilithium_mode_from_string(oid.to_formatted_string())) {}

◆ DilithiumMode() [3/3]

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

Definition at line 67 of file dilithium.cpp.

67: m_mode(dilithium_mode_from_string(str)) {}

Member Function Documentation

◆ is_aes()

bool Botan::DilithiumMode::is_aes ( ) const

Definition at line 98 of file dilithium.cpp.

98 {
99 return m_mode == Dilithium4x4_AES || m_mode == Dilithium6x5_AES || m_mode == Dilithium8x7_AES;
100}

References Dilithium4x4_AES, Dilithium6x5_AES, and Dilithium8x7_AES.

Referenced by Botan::DilithiumConstants::is_aes(), is_available(), and is_modern().

◆ is_available()

bool Botan::DilithiumMode::is_available ( ) const

Definition at line 110 of file dilithium.cpp.

110 {
111#if defined(BOTAN_HAS_DILITHIUM_AES)
112 if(is_dilithium_round3() && is_aes()) {
113 return true;
114 }
115#endif
116#if defined(BOTAN_HAS_DILITHIUM)
117 if(is_dilithium_round3() && is_modern()) {
118 return true;
119 }
120#endif
121#if defined(BOTAN_HAS_ML_DSA)
122 if(is_ml_dsa()) {
123 return true;
124 }
125#endif
126 return false;
127}
bool is_aes() const
Definition dilithium.cpp:98
bool is_modern() const
bool is_dilithium_round3() const
Definition dilithium.h:48
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 48 of file dilithium.h.

48{ return !is_ml_dsa(); }

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

◆ is_ml_dsa()

bool Botan::DilithiumMode::is_ml_dsa ( ) const

Definition at line 106 of file dilithium.cpp.

106 {
107 return m_mode == ML_DSA_4x4 || m_mode == ML_DSA_6x5 || m_mode == ML_DSA_8x7;
108}

References ML_DSA_4x4, ML_DSA_6x5, and ML_DSA_8x7.

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

◆ is_modern()

bool Botan::DilithiumMode::is_modern ( ) const

Definition at line 102 of file dilithium.cpp.

102 {
103 return !is_aes();
104}

References is_aes().

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

◆ mode()

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

Definition at line 52 of file dilithium.h.

52{ return m_mode; }

Referenced by Botan::DilithiumConstants::DilithiumConstants().

◆ object_identifier()

OID Botan::DilithiumMode::object_identifier ( ) const

Definition at line 69 of file dilithium.cpp.

69 {
71}
std::string to_string() const
Definition dilithium.cpp:73
static OID from_string(std::string_view str)
Definition asn1_oid.cpp:86

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

◆ to_string()

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

Definition at line 73 of file dilithium.cpp.

73 {
74 switch(m_mode) {
76 return "Dilithium-4x4-r3";
78 return "Dilithium-4x4-AES-r3";
80 return "Dilithium-6x5-r3";
82 return "Dilithium-6x5-AES-r3";
84 return "Dilithium-8x7-r3";
86 return "Dilithium-8x7-AES-r3";
88 return "ML-DSA-4x4";
90 return "ML-DSA-6x5";
92 return "ML-DSA-8x7";
93 }
94
96}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:137

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: