Botan 2.19.5 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
13 BOTAN_FUTURE_INTERNAL_HEADER(sha2_64.h)
14
15namespace Botan {
16
17/**
18* SHA-384
19*/
20 class BOTAN_PUBLIC_API(2,0) SHA_384 final : public MDx_HashFunction
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
37 secure_vector<uint64_t> m_digest;
38 };
39
40/**
41* SHA-512
42*/
43 class BOTAN_PUBLIC_API(2,0) SHA_512 final : public MDx_HashFunction
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
75 secure_vector<uint64_t> m_digest;
76 };
77
78/**
79* SHA-512/256
80*/
81 class BOTAN_PUBLIC_API(2,0) SHA_512_256 final : public MDx_HashFunction
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
97 secure_vector<uint64_t> m_digest;
98 };
99
100}
101
102#endif
Botan::HashFunction
Definition: hash.h:21
Botan::HashFunction::provider
virtual std::string provider() const
Definition: hash.h:58
Botan::HashFunction::copy_state
virtual std::unique_ptr< HashFunction > copy_state() const =0
Botan::MDx_HashFunction
Definition: mdx_hash.h:21
Botan::MDx_HashFunction::clear
void clear() override
Definition: mdx_hash.cpp:41
Botan::MDx_HashFunction::compress_n
virtual void compress_n(const uint8_t blocks[], size_t block_n)=0
Botan::MDx_HashFunction::copy_out
virtual void copy_out(uint8_t buffer[])=0
Botan::SHA_384
Definition: sha2_64.h:21
Botan::SHA_384::name
std::string name() const override
Definition: sha2_64.h:23
Botan::SHA_384::clone
HashFunction * clone() const override
Definition: sha2_64.h:25
Botan::SHA_384::SHA_384
SHA_384()
Definition: sha2_64.h:31
Botan::SHA_384::output_length
size_t output_length() const override
Definition: sha2_64.h:24
Botan::SHA_512_256
Definition: sha2_64.h:82
Botan::SHA_512_256::SHA_512_256
SHA_512_256()
Definition: sha2_64.h:92
Botan::SHA_512_256::output_length
size_t output_length() const override
Definition: sha2_64.h:85
Botan::SHA_512_256::clone
HashFunction * clone() const override
Definition: sha2_64.h:86
Botan::SHA_512_256::name
std::string name() const override
Definition: sha2_64.h:84
Botan::SHA_512
Definition: sha2_64.h:44
Botan::SHA_512::output_length
size_t output_length() const override
Definition: sha2_64.h:47
Botan::SHA_512::SHA_512
SHA_512()
Definition: sha2_64.h:61
Botan::SHA_512::clone
HashFunction * clone() const override
Definition: sha2_64.h:48
Botan::SHA_512::name
std::string name() const override
Definition: sha2_64.h:46
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
BOTAN_FUTURE_INTERNAL_HEADER
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Botan
Definition: alg_id.cpp:13
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65