Botan 2.19.1
Crypto and TLS for C&
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
14
15namespace Botan {
16
17/**
18* SHA-384
19*/
21 {
22 public:
23 std::string name() const override { return "SHA-384"; }
24 size_t output_length() const override { return 48; }
25 HashFunction* clone() const override { return new SHA_384; }
26 std::unique_ptr<HashFunction> copy_state() const override;
27 std::string provider() const override;
28
29 void clear() override;
30
31 SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
32 { clear(); }
33 private:
34 void compress_n(const uint8_t[], size_t blocks) override;
35 void copy_out(uint8_t[]) override;
36
38 };
39
40/**
41* SHA-512
42*/
44 {
45 public:
46 std::string name() const override { return "SHA-512"; }
47 size_t output_length() const override { return 64; }
48 HashFunction* clone() const override { return new SHA_512; }
49 std::unique_ptr<HashFunction> copy_state() const override;
50 std::string provider() const override;
51
52 void clear() override;
53
54 /*
55 * Perform a SHA-512 compression. For internal use
56 */
57 static void compress_digest(secure_vector<uint64_t>& digest,
58 const uint8_t input[],
59 size_t blocks);
60
61 SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
62 { clear(); }
63 private:
64 void compress_n(const uint8_t[], size_t blocks) override;
65 void copy_out(uint8_t[]) override;
66
67 static const uint64_t K[80];
68
69#if defined(BOTAN_HAS_SHA2_64_BMI2)
70 static void compress_digest_bmi2(secure_vector<uint64_t>& digest,
71 const uint8_t input[],
72 size_t blocks);
73#endif
74
76 };
77
78/**
79* SHA-512/256
80*/
82 {
83 public:
84 std::string name() const override { return "SHA-512-256"; }
85 size_t output_length() const override { return 32; }
86 HashFunction* clone() const override { return new SHA_512_256; }
87 std::unique_ptr<HashFunction> copy_state() const override;
88 std::string provider() const override;
89
90 void clear() override;
91
92 SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
93 private:
94 void compress_n(const uint8_t[], size_t blocks) override;
95 void copy_out(uint8_t[]) override;
96
98 };
99
100}
101
102#endif
virtual std::string provider() const
Definition: hash.h:58
virtual std::unique_ptr< HashFunction > copy_state() const =0
void clear() override
Definition: mdx_hash.cpp:41
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
virtual void copy_out(uint8_t buffer[])=0
std::string name() const override
Definition: sha2_64.h:23
HashFunction * clone() const override
Definition: sha2_64.h:25
size_t output_length() const override
Definition: sha2_64.h:24
size_t output_length() const override
Definition: sha2_64.h:85
HashFunction * clone() const override
Definition: sha2_64.h:86
std::string name() const override
Definition: sha2_64.h:84
size_t output_length() const override
Definition: sha2_64.h:47
HashFunction * clone() const override
Definition: sha2_64.h:48
std::string name() const override
Definition: sha2_64.h:46
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65