Coverage Report

Created: 2026-04-01 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/botan/build/include/internal/botan/internal/blake2s.h
Line
Count
Source
1
/*
2
 * BLAKE2s
3
 * (C) 2023, 2025       Richard Huveneers
4
 * (C) 2025             Kagan Can Sit
5
 * (C) 2025             René Meusel, Rohde & Schwarz Cybersecurity
6
 *
7
 * Botan is released under the Simplified BSD License (see license.txt)
8
 */
9
10
#ifndef BOTAN_BLAKE2S_H_
11
#define BOTAN_BLAKE2S_H_
12
13
#include <botan/hash.h>
14
#include <botan/internal/alignment_buffer.h>
15
16
namespace Botan {
17
18
/**
19
 * BLAKE2s
20
 */
21
class BLAKE2s final : public HashFunction {
22
   private:
23
      static constexpr size_t block_size = 64;
24
25
   public:
26
      explicit BLAKE2s(size_t output_bits = 256);
27
      ~BLAKE2s() override;
28
29
0
      BLAKE2s(const BLAKE2s&) = default;
30
      BLAKE2s& operator=(const BLAKE2s&) = delete;
31
      BLAKE2s(BLAKE2s&&) = delete;
32
      BLAKE2s& operator=(BLAKE2s&&) = delete;
33
34
      std::string name() const override;
35
36
0
      size_t output_length() const override { return m_outlen; }
37
38
0
      size_t hash_block_size() const override { return block_size; }
39
40
      std::unique_ptr<HashFunction> copy_state() const override;
41
42
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<BLAKE2s>(m_outlen << 3); }
43
44
      void clear() override;
45
46
   private:
47
      void add_data(std::span<const uint8_t> input) override;
48
      void final_result(std::span<uint8_t> output) override;
49
      void state_init(size_t outlen);
50
      void compress(bool last, std::span<const uint8_t> buf);
51
52
   private:
53
      uint64_t m_bytes_processed = 0;
54
      AlignmentBuffer<uint8_t, block_size, AlignmentBufferFinalBlock::must_be_deferred> m_buffer;
55
56
      std::array<uint32_t, 8> m_h{};  // chained state
57
      size_t m_outlen = 0;            // digest size
58
};
59
60
}  // namespace Botan
61
62
#endif