Botan  2.4.0
Crypto and TLS for C++11
sha160.h
Go to the documentation of this file.
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 namespace Botan {
14 
15 /**
16 * NIST's SHA-160
17 */
18 class BOTAN_PUBLIC_API(2,0) SHA_160 final : public MDx_HashFunction
19  {
20  public:
21  std::string name() const override { return "SHA-160"; }
22  size_t output_length() const override { return 20; }
23  HashFunction* clone() const override { return new SHA_160; }
24  std::unique_ptr<HashFunction> copy_state() const override;
25 
26  void clear() override;
27 
28  SHA_160() : MDx_HashFunction(64, true, true), m_digest(5)
29  {
30  clear();
31  }
32 
33  private:
34  void compress_n(const uint8_t[], size_t blocks) override;
35 
36 #if defined(BOTAN_HAS_SHA1_ARMV8)
37  static void sha1_armv8_compress_n(secure_vector<uint32_t>& digest,
38  const uint8_t blocks[],
39  size_t block_count);
40 #endif
41 
42 #if defined(BOTAN_HAS_SHA1_SSE2)
43  static void sse2_compress_n(secure_vector<uint32_t>& digest,
44  const uint8_t blocks[],
45  size_t block_count);
46 #endif
47 
48 #if defined(BOTAN_HAS_SHA1_X86_SHA_NI)
49  // Using x86 SHA instructions in Intel Goldmont and Cannonlake
50  static void sha1_compress_x86(secure_vector<uint32_t>& digest,
51  const uint8_t blocks[],
52  size_t block_count);
53 #endif
54 
55 
56  void copy_out(uint8_t[]) override;
57 
58  /**
59  * The digest value
60  */
61  secure_vector<uint32_t> m_digest;
62 
63  /**
64  * The message buffer
65  */
67  };
68 
69 typedef SHA_160 SHA_1;
70 
71 }
72 
73 #endif
HashFunction * clone() const override
Definition: sha160.h:23
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
SHA_160 SHA_1
Definition: sha160.h:69
size_t output_length() const override
Definition: sha160.h:22
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
std::string name() const override
Definition: sha160.h:21