Coverage Report

Created: 2021-06-10 10:30

/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
   {
20
   public:
21
98
      std::string name() const override { return "SHA-384"; }
22
74.1k
      size_t output_length() const override { return 48; }
23
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_384>(); }
24
      std::unique_ptr<HashFunction> copy_state() const override;
25
      std::string provider() const override;
26
27
      void clear() override;
28
29
      SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
30
2.70k
         { clear(); }
31
   private:
32
      void compress_n(const uint8_t[], size_t blocks) override;
33
      void copy_out(uint8_t[]) override;
34
35
      secure_vector<uint64_t> m_digest;
36
   };
37
38
/**
39
* SHA-512
40
*/
41
class SHA_512 final : public MDx_HashFunction
42
   {
43
   public:
44
2
      std::string name() const override { return "SHA-512"; }
45
31
      size_t output_length() const override { return 64; }
46
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_512>(); }
47
      std::unique_ptr<HashFunction> copy_state() const override;
48
      std::string provider() const override;
49
50
      void clear() override;
51
52
      /*
53
      * Perform a SHA-512 compression. For internal use
54
      */
55
      static void compress_digest(secure_vector<uint64_t>& digest,
56
                                  const uint8_t input[],
57
                                  size_t blocks);
58
59
      SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
60
11
         { clear(); }
61
   private:
62
      void compress_n(const uint8_t[], size_t blocks) override;
63
      void copy_out(uint8_t[]) override;
64
65
      static const uint64_t K[80];
66
67
#if defined(BOTAN_HAS_SHA2_64_BMI2)
68
      static void compress_digest_bmi2(secure_vector<uint64_t>& digest,
69
                                       const uint8_t input[],
70
                                       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
   {
81
   public:
82
45
      std::string name() const override { return "SHA-512-256"; }
83
4.05k
      size_t output_length() const override { return 32; }
84
0
      std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_512_256>(); }
85
      std::unique_ptr<HashFunction> copy_state() const override;
86
      std::string provider() const override;
87
88
      void clear() override;
89
90
479
      SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
91
   private:
92
      void compress_n(const uint8_t[], size_t blocks) override;
93
      void copy_out(uint8_t[]) override;
94
95
      secure_vector<uint64_t> m_digest;
96
   };
97
98
}
99
100
#endif