Coverage Report

Created: 2020-05-23 13:54

/src/botan/build/include/botan/sha160.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* SHA-160
3
* (C) 1999-2007,2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_SHA_160_H_
9
#define BOTAN_SHA_160_H_
10
11
#include <botan/mdx_hash.h>
12
13
BOTAN_FUTURE_INTERNAL_HEADER(sha160.h)
14
15
namespace Botan {
16
17
/**
18
* NIST's SHA-160
19
*/
20
class BOTAN_PUBLIC_API(2,0) SHA_160 final : public MDx_HashFunction
21
   {
22
   public:
23
897
      std::string name() const override { return "SHA-160"; }
24
65.3k
      size_t output_length() const override { return 20; }
25
0
      HashFunction* clone() const override { return new SHA_160; }
26
      std::unique_ptr<HashFunction> copy_state() const override;
27
28
      void clear() override;
29
30
      SHA_160() : MDx_HashFunction(64, true, true), m_digest(5)
31
21.7k
         {
32
21.7k
         clear();
33
21.7k
         }
34
35
   private:
36
      void compress_n(const uint8_t[], size_t blocks) override;
37
38
#if defined(BOTAN_HAS_SHA1_ARMV8)
39
      static void sha1_armv8_compress_n(secure_vector<uint32_t>& digest,
40
                                        const uint8_t blocks[],
41
                                        size_t block_count);
42
#endif
43
44
#if defined(BOTAN_HAS_SHA1_SSE2)
45
      static void sse2_compress_n(secure_vector<uint32_t>& digest,
46
                                  const uint8_t blocks[],
47
                                  size_t block_count);
48
#endif
49
50
#if defined(BOTAN_HAS_SHA1_X86_SHA_NI)
51
      // Using x86 SHA instructions in Intel Goldmont and Cannonlake
52
      static void sha1_compress_x86(secure_vector<uint32_t>& digest,
53
                                    const uint8_t blocks[],
54
                                    size_t block_count);
55
#endif
56
57
58
      void copy_out(uint8_t[]) override;
59
60
      /**
61
      * The digest value
62
      */
63
      secure_vector<uint32_t> m_digest;
64
65
      /**
66
      * The message buffer
67
      */
68
      secure_vector<uint32_t> m_W;
69
   };
70
71
typedef SHA_160 SHA_1;
72
73
}
74
75
#endif