Coverage Report

Created: 2020-11-21 08:34

/src/botan/build/include/botan/internal/sha2_32.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* SHA-{224,256}
3
* (C) 1999-2011 Jack Lloyd
4
*     2007 FlexSecure GmbH
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8
9
#ifndef BOTAN_SHA_224_256_H_
10
#define BOTAN_SHA_224_256_H_
11
12
#include <botan/internal/mdx_hash.h>
13
14
namespace Botan {
15
16
/**
17
* SHA-224
18
*/
19
class SHA_224 final : public MDx_HashFunction
20
   {
21
   public:
22
5
      std::string name() const override { return "SHA-224"; }
23
493
      size_t output_length() const override { return 28; }
24
0
      HashFunction* clone() const override { return new SHA_224; }
25
      std::unique_ptr<HashFunction> copy_state() const override;
26
27
      void clear() override;
28
29
      std::string provider() const override;
30
31
      SHA_224() : MDx_HashFunction(64, true, true), m_digest(8)
32
146
         { 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<uint32_t> m_digest;
38
   };
39
40
/**
41
* SHA-256
42
*/
43
class SHA_256 final : public MDx_HashFunction
44
   {
45
   public:
46
5.95k
      std::string name() const override { return "SHA-256"; }
47
809k
      size_t output_length() const override { return 32; }
48
0
      HashFunction* clone() const override { return new SHA_256; }
49
      std::unique_ptr<HashFunction> copy_state() const override;
50
51
      void clear() override;
52
53
      std::string provider() const override;
54
55
      SHA_256() : MDx_HashFunction(64, true, true), m_digest(8)
56
109k
         { clear(); }
57
58
      /*
59
      * Perform a SHA-256 compression. For internal use
60
      */
61
      static void compress_digest(secure_vector<uint32_t>& digest,
62
                                  const uint8_t input[],
63
                                  size_t blocks);
64
65
   private:
66
67
#if defined(BOTAN_HAS_SHA2_32_ARMV8)
68
      static void compress_digest_armv8(secure_vector<uint32_t>& digest,
69
                                        const uint8_t input[],
70
                                        size_t blocks);
71
#endif
72
73
#if defined(BOTAN_HAS_SHA2_32_X86_BMI2)
74
      static void compress_digest_x86_bmi2(secure_vector<uint32_t>& digest,
75
                                           const uint8_t input[],
76
                                           size_t blocks);
77
#endif
78
79
#if defined(BOTAN_HAS_SHA2_32_X86)
80
      static void compress_digest_x86(secure_vector<uint32_t>& digest,
81
                                      const uint8_t input[],
82
                                      size_t blocks);
83
#endif
84
85
      void compress_n(const uint8_t[], size_t blocks) override;
86
      void copy_out(uint8_t[]) override;
87
88
      secure_vector<uint32_t> m_digest;
89
   };
90
91
}
92
93
#endif