Botan 3.12.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 66 of file dilithium.cpp.

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

◆ DilithiumMode() [3/3]

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

Definition at line 68 of file dilithium.cpp.

68: m_mode(dilithium_mode_from_string(str)) {}

Member Function Documentation

◆ is_aes()

bool Botan::DilithiumMode::is_aes ( ) const

Definition at line 99 of file dilithium.cpp.

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

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

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

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

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

103 {
104 return !is_aes();
105}

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

70 {
72}
std::string to_string() const
Definition dilithium.cpp:74
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 74 of file dilithium.cpp.

74 {
75 switch(m_mode) {
77 return "Dilithium-4x4-r3";
79 return "Dilithium-4x4-AES-r3";
81 return "Dilithium-6x5-r3";
83 return "Dilithium-6x5-AES-r3";
85 return "Dilithium-8x7-r3";
87 return "Dilithium-8x7-AES-r3";
89 return "ML-DSA-4x4";
91 return "ML-DSA-6x5";
93 return "ML-DSA-8x7";
94 }
95
97}
#define BOTAN_ASSERT_UNREACHABLE()
Definition assert.h:163

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: