Botan 3.11.0
Crypto and TLS for C&
Botan::DilithiumMessageHash Class Reference

#include <dilithium_symmetric_primitives.h>

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

Public Member Functions

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

Detailed Description

Wrapper type for the H() function calculating the message representative for the Dilithium signature scheme. This wrapper may be used multiple times.

Namely: mu = H(tr || M)

Definition at line 28 of file dilithium_symmetric_primitives.h.

Constructor & Destructor Documentation

◆ DilithiumMessageHash()

Botan::DilithiumMessageHash::DilithiumMessageHash ( DilithiumHashedPublicKey tr)
explicit

Definition at line 30 of file dilithium_symmetric_primitives.cpp.

30 :
31 m_tr(std::move(tr)), m_shake(XOF::create_or_throw("SHAKE-256")) {}
static std::unique_ptr< XOF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition xof.cpp:54

◆ ~DilithiumMessageHash()

Botan::DilithiumMessageHash::~DilithiumMessageHash ( )
virtualdefault

Member Function Documentation

◆ final()

DilithiumMessageRepresentative Botan::DilithiumMessageHash::final ( )
inline

Definition at line 53 of file dilithium_symmetric_primitives.h.

53 {
54 ensure_started();
55 const scoped_cleanup clean([this]() { clear(); });
57 }
static constexpr size_t MESSAGE_HASH_BYTES
Strong< std::vector< uint8_t >, struct DilithiumMessageRepresentative_ > DilithiumMessageRepresentative
Representation of the message to be signed.

References Botan::DilithiumConstants::MESSAGE_HASH_BYTES.

◆ is_valid_user_context()

virtual bool Botan::DilithiumMessageHash::is_valid_user_context ( std::span< const uint8_t > user_context) const
inlinevirtual

Reimplemented in Botan::ML_DSA_MessageHash.

Definition at line 36 of file dilithium_symmetric_primitives.h.

36 {
37 // Only ML-DSA supports user contexts, for all other modes it must be empty.
38 return user_context.empty();
39 }

Referenced by start().

◆ name()

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

Definition at line 35 of file dilithium_symmetric_primitives.cpp.

35 {
36 return Botan::fmt("{}({})", m_shake->name(), DilithiumConstants::MESSAGE_HASH_BYTES * 8);
37}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

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

◆ start()

virtual void Botan::DilithiumMessageHash::start ( std::span< const uint8_t > user_context)
inlinevirtual

Reimplemented in Botan::ML_DSA_MessageHash.

Definition at line 41 of file dilithium_symmetric_primitives.h.

41 {
42 BOTAN_STATE_CHECK(!m_was_started);
43 BOTAN_ARG_CHECK(is_valid_user_context(user_context), "Invalid user context");
44 m_was_started = true;
45 update(m_tr); // see calculation of mu in FIPS 204, Algorithm 7, line 6
46 }
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
void update(std::span< const uint8_t > data)
virtual bool is_valid_user_context(std::span< const uint8_t > user_context) const

References BOTAN_ARG_CHECK, BOTAN_STATE_CHECK, is_valid_user_context(), and update().

Referenced by Botan::ML_DSA_MessageHash::start().

◆ update()

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

Definition at line 48 of file dilithium_symmetric_primitives.h.

48 {
49 ensure_started();
50 m_shake->update(data);
51 }

Referenced by start(), and Botan::ML_DSA_MessageHash::start().


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