Botan 3.6.1
Crypto and TLS for C&
Botan::ML_DSA_MessageHash Class Referencefinal

#include <ml_dsa_impl.h>

Inheritance diagram for Botan::ML_DSA_MessageHash:
Botan::DilithiumMessageHash

Public Member Functions

 DilithiumMessageHash (DilithiumHashedPublicKey tr)
 
DilithiumMessageRepresentative final ()
 
bool is_valid_user_context (std::span< const uint8_t > user_context) const final
 
std::string name () const
 
void start (std::span< const uint8_t > user_context) final
 
void update (std::span< const uint8_t > data)
 

Detailed Description

Definition at line 28 of file ml_dsa_impl.h.

Member Function Documentation

◆ DilithiumMessageHash()

Botan::DilithiumMessageHash::DilithiumMessageHash ( DilithiumHashedPublicKey tr)
inline

Definition at line 33 of file dilithium_symmetric_primitives.h.

33: m_tr(std::move(tr)) { clear(); }

◆ final()

DilithiumMessageRepresentative Botan::DilithiumMessageHash::final ( )
inlineinherited

Definition at line 58 of file dilithium_symmetric_primitives.h.

58 {
59 ensure_started();
60 scoped_cleanup clean([this]() { clear(); });
62 }
static constexpr size_t MESSAGE_HASH_BYTES
T output(size_t bytes)
Definition xof.h:155
Strong< std::vector< uint8_t >, struct DilithiumMessageRepresentative_ > DilithiumMessageRepresentative
Representation of the message to be signed.

References Botan::DilithiumConstants::MESSAGE_HASH_BYTES, and Botan::XOF::output().

◆ is_valid_user_context()

bool Botan::ML_DSA_MessageHash::is_valid_user_context ( std::span< const uint8_t > user_context) const
inlinefinalvirtual

Reimplemented from Botan::DilithiumMessageHash.

Definition at line 32 of file ml_dsa_impl.h.

32 {
33 return user_context.size() <= 255;
34 }

◆ name()

std::string Botan::DilithiumMessageHash::name ( ) const
inlineinherited

Definition at line 37 of file dilithium_symmetric_primitives.h.

37 {
38 return Botan::fmt("{}({})", m_shake.name(), DilithiumConstants::MESSAGE_HASH_BYTES * 8);
39 }
std::string name() const final
Definition shake_xof.h:70
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::fmt(), Botan::DilithiumConstants::MESSAGE_HASH_BYTES, and Botan::SHAKE_256_XOF::name().

◆ start()

void Botan::ML_DSA_MessageHash::start ( std::span< const uint8_t > user_context)
inlinefinalvirtual

Reimplemented from Botan::DilithiumMessageHash.

Definition at line 36 of file ml_dsa_impl.h.

36 {
37 // ML-DSA introduced an application-specific context string that is
38 // empty by default and can be set by the application.
39 //
40 // In HashML-DSA, there's an additional domain information, namely
41 // the serialized OID of the hash function used to hash the message.
42 //
43 // See FIPS 204, Algorithm 2, line 10 and Algorithm 7, line 6, and
44 // FIPS 204, Section 5.4
45
46 DilithiumMessageHash::start(user_context);
47 constexpr uint8_t domain_separator = 0x00; // HashML-DSA would use 0x01
48 const uint8_t context_length = checked_cast_to<uint8_t>(user_context.size());
49 update(std::array{domain_separator, context_length});
50 update(user_context);
51 }
virtual void start(std::span< const uint8_t > user_context)
int(* update)(CTX *, const void *, CC_LONG len)
constexpr RT checked_cast_to(AT i)
Definition int_utils.h:74

References Botan::checked_cast_to(), Botan::DilithiumMessageHash::start(), and update.

◆ update()

void Botan::DilithiumMessageHash::update ( std::span< const uint8_t > data)
inlineinherited

Definition at line 53 of file dilithium_symmetric_primitives.h.

53 {
54 ensure_started();
55 m_shake.update(data);
56 }
void update(std::span< const uint8_t > input)
Definition xof.h:142

References Botan::XOF::update().


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