Botan  2.4.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 */
18 class BOTAN_PUBLIC_API(2,0) SHA_384 final : public MDx_HashFunction
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 
26  void clear() override;
27 
28  SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
29  { clear(); }
30  private:
31  void compress_n(const uint8_t[], size_t blocks) override;
32  void copy_out(uint8_t[]) override;
33 
34  secure_vector<uint64_t> m_digest;
35  };
36 
37 /**
38 * SHA-512
39 */
40 class BOTAN_PUBLIC_API(2,0) SHA_512 final : public MDx_HashFunction
41  {
42  public:
43  std::string name() const override { return "SHA-512"; }
44  size_t output_length() const override { return 64; }
45  HashFunction* clone() const override { return new SHA_512; }
46  std::unique_ptr<HashFunction> copy_state() const override;
47 
48  void clear() override;
49 
50  SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
51  { clear(); }
52  private:
53  void compress_n(const uint8_t[], size_t blocks) override;
54  void copy_out(uint8_t[]) override;
55 
56  secure_vector<uint64_t> m_digest;
57  };
58 
59 /**
60 * SHA-512/256
61 */
63  {
64  public:
65  std::string name() const override { return "SHA-512-256"; }
66  size_t output_length() const override { return 32; }
67  HashFunction* clone() const override { return new SHA_512_256; }
68  std::unique_ptr<HashFunction> copy_state() const override;
69 
70  void clear() override;
71 
72  SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
73  private:
74  void compress_n(const uint8_t[], size_t blocks) override;
75  void copy_out(uint8_t[]) override;
76 
77  secure_vector<uint64_t> m_digest;
78  };
79 
80 }
81 
82 #endif
size_t output_length() const override
Definition: sha2_64.h:66
std::string name() const override
Definition: sha2_64.h:65
std::string name() const override
Definition: sha2_64.h:21
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
std::string name() const override
Definition: sha2_64.h:43
size_t output_length() const override
Definition: sha2_64.h:44
HashFunction * clone() const override
Definition: sha2_64.h:67
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:88
HashFunction * clone() const override
Definition: sha2_64.h:45