Botan  2.13.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 
14 
15 namespace Botan {
16 
17 /**
18 * NIST's SHA-160
19 */
21  {
22  public:
23  std::string name() const override { return "SHA-160"; }
24  size_t output_length() const override { return 20; }
25  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  {
32  clear();
33  }
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  */
69  };
70 
71 typedef SHA_160 SHA_1;
72 
73 }
74 
75 #endif
void clear() override
Definition: mdx_hash.cpp:41
HashFunction * clone() const override
Definition: sha160.h:25
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
SHA_160 SHA_1
Definition: sha160.h:71
size_t output_length() const override
Definition: sha160.h:24
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
virtual void copy_out(uint8_t buffer[])=0
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
virtual std::unique_ptr< HashFunction > copy_state() const =0
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139
std::string name() const override
Definition: sha160.h:23