Botan 3.6.1
Crypto and TLS for C&
Botan::MerkleDamgard_Hash< MD > Class Template Referencefinal

#include <mdx_hash.h>

Public Member Functions

void clear ()
 
void final (std::span< uint8_t > output)
 
 MerkleDamgard_Hash ()
 
void update (std::span< const uint8_t > input)
 

Detailed Description

template<md_hash_implementation MD>
class Botan::MerkleDamgard_Hash< MD >

Definition at line 40 of file mdx_hash.h.

Constructor & Destructor Documentation

◆ MerkleDamgard_Hash()

template<md_hash_implementation MD>
Botan::MerkleDamgard_Hash< MD >::MerkleDamgard_Hash ( )
inline

Definition at line 42 of file mdx_hash.h.

42{ clear(); }

References Botan::MerkleDamgard_Hash< MD >::clear().

Member Function Documentation

◆ clear()

template<md_hash_implementation MD>
void Botan::MerkleDamgard_Hash< MD >::clear ( )
inline

Definition at line 70 of file mdx_hash.h.

70 {
71 MD::init(m_digest);
72 m_buffer.clear();
73 m_count = 0;
74 }

References Botan::AlignmentBuffer< T, BLOCK_SIZE, FINAL_BLOCK_STRATEGY >::clear().

Referenced by Botan::MerkleDamgard_Hash< MD >::final(), and Botan::MerkleDamgard_Hash< MD >::MerkleDamgard_Hash().

◆ final()

template<md_hash_implementation MD>
void Botan::MerkleDamgard_Hash< MD >::final ( std::span< uint8_t > output)
inline

Definition at line 63 of file mdx_hash.h.

63 {
64 append_padding_bit();
65 append_counter_and_finalize();
66 copy_output(output);
67 clear();
68 }

References Botan::MerkleDamgard_Hash< MD >::clear().

◆ update()

template<md_hash_implementation MD>
void Botan::MerkleDamgard_Hash< MD >::update ( std::span< const uint8_t > input)
inline

Definition at line 44 of file mdx_hash.h.

44 {
45 BufferSlicer in(input);
46
47 while(!in.empty()) {
48 if(const auto one_block = m_buffer.handle_unaligned_data(in)) {
49 MD::compress_n(m_digest, one_block.value(), 1);
50 }
51
52 if(m_buffer.in_alignment()) {
53 const auto [aligned_data, full_blocks] = m_buffer.aligned_data_to_process(in);
54 if(full_blocks > 0) {
55 MD::compress_n(m_digest, aligned_data, full_blocks);
56 }
57 }
58 }
59
60 m_count += input.size();
61 }
std::tuple< std::span< const uint8_t >, size_t > aligned_data_to_process(BufferSlicer &slicer) const
std::optional< std::span< const T > > handle_unaligned_data(BufferSlicer &slicer)

References Botan::AlignmentBuffer< T, BLOCK_SIZE, FINAL_BLOCK_STRATEGY >::aligned_data_to_process(), Botan::BufferSlicer::empty(), Botan::AlignmentBuffer< T, BLOCK_SIZE, FINAL_BLOCK_STRATEGY >::handle_unaligned_data(), and Botan::AlignmentBuffer< T, BLOCK_SIZE, FINAL_BLOCK_STRATEGY >::in_alignment().


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