Botan  2.10.0
Crypto and TLS for C++11
sha2_64.h
Go to the documentation of this file.
1 /*
2 * SHA-{384,512}
3 * (C) 1999-2010,2015 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_SHA_64BIT_H_
9 #define BOTAN_SHA_64BIT_H_
10 
11 #include <botan/mdx_hash.h>
12 
13 namespace Botan {
14 
15 /**
16 * SHA-384
17 */
19  {
20  public:
21  std::string name() const override { return "SHA-384"; }
22  size_t output_length() const override { return 48; }
23  HashFunction* clone() const override { return new SHA_384; }
24  std::unique_ptr<HashFunction> copy_state() const override;
25  std::string provider() const override;
26 
27  void clear() override;
28 
29  SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
30  { clear(); }
31  private:
32  void compress_n(const uint8_t[], size_t blocks) override;
33  void copy_out(uint8_t[]) override;
34 
35  secure_vector<uint64_t> m_digest;
36  };
37 
38 /**
39 * SHA-512
40 */
42  {
43  public:
44  std::string name() const override { return "SHA-512"; }
45  size_t output_length() const override { return 64; }
46  HashFunction* clone() const override { return new SHA_512; }
47  std::unique_ptr<HashFunction> copy_state() const override;
48  std::string provider() const override;
49 
50  void clear() override;
51 
52  /*
53  * Perform a SHA-512 compression. For internal use
54  */
55  static void compress_digest(secure_vector<uint64_t>& digest,
56  const uint8_t input[],
57  size_t blocks);
58 
59  SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
60  { clear(); }
61  private:
62  void compress_n(const uint8_t[], size_t blocks) override;
63  void copy_out(uint8_t[]) override;
64 
65  static const uint64_t K[80];
66 
67 #if defined(BOTAN_HAS_SHA2_64_BMI2)
68  static void compress_digest_bmi2(secure_vector<uint64_t>& digest,
69  const uint8_t input[],
70  size_t blocks);
71 #endif
72 
73  secure_vector<uint64_t> m_digest;
74  };
75 
76 /**
77 * SHA-512/256
78 */
80  {
81  public:
82  std::string name() const override { return "SHA-512-256"; }
83  size_t output_length() const override { return 32; }
84  HashFunction* clone() const override { return new SHA_512_256; }
85  std::unique_ptr<HashFunction> copy_state() const override;
86  std::string provider() const override;
87 
88  void clear() override;
89 
90  SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
91  private:
92  void compress_n(const uint8_t[], size_t blocks) override;
93  void copy_out(uint8_t[]) override;
94 
95  secure_vector<uint64_t> m_digest;
96  };
97 
98 }
99 
100 #endif
size_t output_length() const override
Definition: sha2_64.h:83
std::string name() const override
Definition: sha2_64.h:82
std::string name() const override
Definition: sha2_64.h:21
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
std::string name() const override
Definition: sha2_64.h:44
size_t output_length() const override
Definition: sha2_64.h:45
HashFunction * clone() const override
Definition: sha2_64.h:84
size_t output_length() const override
Definition: sha2_64.h:22
Definition: alg_id.cpp:13
HashFunction * clone() const override
Definition: sha2_64.h:23
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
HashFunction * clone() const override
Definition: sha2_64.h:46