Botan 3.6.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 ()=default
 

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 31 of file dilithium_symmetric_primitives.h.

Constructor & Destructor 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(); }

◆ ~DilithiumMessageHash()

virtual Botan::DilithiumMessageHash::~DilithiumMessageHash ( )
virtualdefault

Member Function Documentation

◆ final()

DilithiumMessageRepresentative Botan::DilithiumMessageHash::final ( )
inline

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()

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 41 of file dilithium_symmetric_primitives.h.

41 {
42 // Only ML-DSA supports user contexts, for all other modes it must be empty.
43 return user_context.empty();
44 }

Referenced by start().

◆ name()

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

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()

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

Reimplemented in Botan::ML_DSA_MessageHash.

Definition at line 46 of file dilithium_symmetric_primitives.h.

46 {
47 BOTAN_STATE_CHECK(!m_was_started);
48 BOTAN_ARG_CHECK(is_valid_user_context(user_context), "Invalid user context");
49 m_was_started = true;
50 update(m_tr); // see calculation of mu in FIPS 204, Algorithm 7, line 6
51 }
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:41
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
virtual bool is_valid_user_context(std::span< const uint8_t > user_context) const
int(* update)(CTX *, const void *, CC_LONG len)

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 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: