Coverage Report

Created: 2020-02-14 15:38

/src/botan/build/include/botan/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/mdx_hash.h>
12
13
BOTAN_FUTURE_INTERNAL_HEADER(sha2_64.h)
14
15
namespace Botan {
16
17
/**
18
* SHA-384
19
*/
20
class BOTAN_PUBLIC_API(2,0) SHA_384 final : public MDx_HashFunction
21
   {
22
   public:
23
310
      std::string name() const override { return "SHA-384"; }
24
189k
      size_t output_length() const override { return 48; }
25
0
      HashFunction* clone() const override { return new SHA_384; }
26
      std::unique_ptr<HashFunction> copy_state() const override;
27
      std::string provider() const override;
28
29
      void clear() override;
30
31
      SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
32
8.10k
         { clear(); }
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 BOTAN_PUBLIC_API(2,0) SHA_512 final : public MDx_HashFunction
44
   {
45
   public:
46
27
      std::string name() const override { return "SHA-512"; }
47
348
      size_t output_length() const override { return 64; }
48
0
      HashFunction* clone() const override { return new SHA_512; }
49
      std::unique_ptr<HashFunction> copy_state() const override;
50
      std::string provider() const override;
51
52
      void clear() override;
53
54
      /*
55
      * Perform a SHA-512 compression. For internal use
56
      */
57
      static void compress_digest(secure_vector<uint64_t>& digest,
58
                                  const uint8_t input[],
59
                                  size_t blocks);
60
61
      SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
62
127
         { clear(); }
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,
71
                                       const uint8_t input[],
72
                                       size_t blocks);
73
#endif
74
75
      secure_vector<uint64_t> m_digest;
76
   };
77
78
/**
79
* SHA-512/256
80
*/
81
class BOTAN_PUBLIC_API(2,0) SHA_512_256 final : public MDx_HashFunction
82
   {
83
   public:
84
17
      std::string name() const override { return "SHA-512-256"; }
85
2.28k
      size_t output_length() const override { return 32; }
86
0
      HashFunction* clone() const override { return new SHA_512_256; }
87
      std::unique_ptr<HashFunction> copy_state() const override;
88
      std::string provider() const override;
89
90
      void clear() override;
91
92
263
      SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
93
   private:
94
      void compress_n(const uint8_t[], size_t blocks) override;
95
      void copy_out(uint8_t[]) override;
96
97
      secure_vector<uint64_t> m_digest;
98
   };
99
100
}
101
102
#endif