Coverage Report

Created: 2020-02-14 15:38

/src/botan/build/include/botan/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/mdx_hash.h>
13
14
BOTAN_FUTURE_INTERNAL_HEADER(sha2_32.h)
15
16
namespace Botan {
17
18
/**
19
* SHA-224
20
*/
21
class BOTAN_PUBLIC_API(2,0) SHA_224 final : public MDx_HashFunction
22
   {
23
   public:
24
6
      std::string name() const override { return "SHA-224"; }
25
53
      size_t output_length() const override { return 28; }
26
0
      HashFunction* clone() const override { return new SHA_224; }
27
      std::unique_ptr<HashFunction> copy_state() const override;
28
29
      void clear() override;
30
31
      std::string provider() const override;
32
33
      SHA_224() : MDx_HashFunction(64, true, true), m_digest(8)
34
19
         { clear(); }
35
   private:
36
      void compress_n(const uint8_t[], size_t blocks) override;
37
      void copy_out(uint8_t[]) override;
38
39
      secure_vector<uint32_t> m_digest;
40
   };
41
42
/**
43
* SHA-256
44
*/
45
class BOTAN_PUBLIC_API(2,0) SHA_256 final : public MDx_HashFunction
46
   {
47
   public:
48
5.97k
      std::string name() const override { return "SHA-256"; }
49
709k
      size_t output_length() const override { return 32; }
50
0
      HashFunction* clone() const override { return new SHA_256; }
51
      std::unique_ptr<HashFunction> copy_state() const override;
52
53
      void clear() override;
54
55
      std::string provider() const override;
56
57
      SHA_256() : MDx_HashFunction(64, true, true), m_digest(8)
58
101k
         { clear(); }
59
60
      /*
61
      * Perform a SHA-256 compression. For internal use
62
      */
63
      static void compress_digest(secure_vector<uint32_t>& digest,
64
                                  const uint8_t input[],
65
                                  size_t blocks);
66
67
   private:
68
69
#if defined(BOTAN_HAS_SHA2_32_ARMV8)
70
      static void compress_digest_armv8(secure_vector<uint32_t>& digest,
71
                                        const uint8_t input[],
72
                                        size_t blocks);
73
#endif
74
75
#if defined(BOTAN_HAS_SHA2_32_X86_BMI2)
76
      static void compress_digest_x86_bmi2(secure_vector<uint32_t>& digest,
77
                                           const uint8_t input[],
78
                                           size_t blocks);
79
#endif
80
81
#if defined(BOTAN_HAS_SHA2_32_X86)
82
      static void compress_digest_x86(secure_vector<uint32_t>& digest,
83
                                      const uint8_t input[],
84
                                      size_t blocks);
85
#endif
86
87
      void compress_n(const uint8_t[], size_t blocks) override;
88
      void copy_out(uint8_t[]) override;
89
90
      secure_vector<uint32_t> m_digest;
91
   };
92
93
}
94
95
#endif