Coverage Report

Created: 2023-06-07 07:00

/src/botan/build/include/botan/internal/sha2_64.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* SHA-{384,512}
3
* (C) 1999-2010,2015 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_SHA_64BIT_H_
9
#define BOTAN_SHA_64BIT_H_
10
11
#include <botan/internal/mdx_hash.h>
12
13
namespace Botan {
14
15
/**
16
* SHA-384
17
*/
18
class SHA_384 final : public MDx_HashFunction {
19
   public:
20
0
      std::string name() const override { return "SHA-384"; }
21
22
0
      size_t output_length() const override { return 48; }
23
24
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_384>(); }
25
26
      std::unique_ptr<HashFunction> copy_state() const override;
27
      std::string provider() const override;
28
29
      void clear() override;
30
31
0
      SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
32
33
   private:
34
      void compress_n(const uint8_t[], size_t blocks) override;
35
      void copy_out(uint8_t[]) override;
36
37
      secure_vector<uint64_t> m_digest;
38
};
39
40
/**
41
* SHA-512
42
*/
43
class SHA_512 final : public MDx_HashFunction {
44
   public:
45
0
      std::string name() const override { return "SHA-512"; }
46
47
0
      size_t output_length() const override { return 64; }
48
49
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_512>(); }
50
51
      std::unique_ptr<HashFunction> copy_state() const override;
52
      std::string provider() const override;
53
54
      void clear() override;
55
56
      /*
57
      * Perform a SHA-512 compression. For internal use
58
      */
59
      static void compress_digest(secure_vector<uint64_t>& digest, const uint8_t input[], size_t blocks);
60
61
0
      SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
62
63
   private:
64
      void compress_n(const uint8_t[], size_t blocks) override;
65
      void copy_out(uint8_t[]) override;
66
67
      static const uint64_t K[80];
68
69
#if defined(BOTAN_HAS_SHA2_64_BMI2)
70
      static void compress_digest_bmi2(secure_vector<uint64_t>& digest, const uint8_t input[], size_t blocks);
71
#endif
72
73
      secure_vector<uint64_t> m_digest;
74
};
75
76
/**
77
* SHA-512/256
78
*/
79
class SHA_512_256 final : public MDx_HashFunction {
80
   public:
81
0
      std::string name() const override { return "SHA-512-256"; }
82
83
0
      size_t output_length() const override { return 32; }
84
85
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_512_256>(); }
86
87
      std::unique_ptr<HashFunction> copy_state() const override;
88
      std::string provider() const override;
89
90
      void clear() override;
91
92
0
      SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
93
94
   private:
95
      void compress_n(const uint8_t[], size_t blocks) override;
96
      void copy_out(uint8_t[]) override;
97
98
      secure_vector<uint64_t> m_digest;
99
};
100
101
}  // namespace Botan
102
103
#endif