Botan 2.19.5 Crypto and TLS for C&

sha2_32.h
Go to the documentation of this file.
1/*
2* SHA-{224,256}
3* (C) 1999-2011 Jack Lloyd
4* 2007 FlexSecure GmbH
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_SHA_224_256_H_
10#define BOTAN_SHA_224_256_H_
11
12#include <botan/mdx_hash.h>
13
14 BOTAN_FUTURE_INTERNAL_HEADER(sha2_32.h)
15
16namespace Botan {
17
18/**
19* SHA-224
20*/
21 class BOTAN_PUBLIC_API(2,0) SHA_224 final : public MDx_HashFunction
22 {
23 public:
24 std::string name() const override { return "SHA-224"; }
25 size_t output_length() const override { return 28; }
26 HashFunction* clone() const override { return new SHA_224; }
27 std::unique_ptr<HashFunction> copy_state() const override;
28
29 void clear() override;
30
31 std::string provider() const override;
32
33 SHA_224() : MDx_HashFunction(64, true, true), m_digest(8)
34 { clear(); }
35 private:
36 void compress_n(const uint8_t[], size_t blocks) override;
37 void copy_out(uint8_t[]) override;
38
39 secure_vector<uint32_t> m_digest;
40 };
41
42/**
43* SHA-256
44*/
45 class BOTAN_PUBLIC_API(2,0) SHA_256 final : public MDx_HashFunction
46 {
47 public:
48 std::string name() const override { return "SHA-256"; }
49 size_t output_length() const override { return 32; }
50 HashFunction* clone() const override { return new SHA_256; }
51 std::unique_ptr<HashFunction> copy_state() const override;
52
53 void clear() override;
54
55 std::string provider() const override;
56
57 SHA_256() : MDx_HashFunction(64, true, true), m_digest(8)
58 { clear(); }
59
60 /*
61 * Perform a SHA-256 compression. For internal use
62 */
63 static void compress_digest(secure_vector<uint32_t>& digest,
64 const uint8_t input[],
65 size_t blocks);
66
67 private:
68
69#if defined(BOTAN_HAS_SHA2_32_ARMV8)
70 static void compress_digest_armv8(secure_vector<uint32_t>& digest,
71 const uint8_t input[],
72 size_t blocks);
73#endif
74
75#if defined(BOTAN_HAS_SHA2_32_X86_BMI2)
76 static void compress_digest_x86_bmi2(secure_vector<uint32_t>& digest,
77 const uint8_t input[],
78 size_t blocks);
79#endif
80
81#if defined(BOTAN_HAS_SHA2_32_X86)
82 static void compress_digest_x86(secure_vector<uint32_t>& digest,
83 const uint8_t input[],
84 size_t blocks);
85#endif
86
87 void compress_n(const uint8_t[], size_t blocks) override;
88 void copy_out(uint8_t[]) override;
89
90 secure_vector<uint32_t> m_digest;
91 };
92
93}
94
95#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_224
Definition: sha2_32.h:22
Botan::SHA_224::SHA_224
SHA_224()
Definition: sha2_32.h:33
Botan::SHA_224::output_length
size_t output_length() const override
Definition: sha2_32.h:25
Botan::SHA_224::clone
HashFunction * clone() const override
Definition: sha2_32.h:26
Botan::SHA_224::name
std::string name() const override
Definition: sha2_32.h:24
Botan::SHA_256
Definition: sha2_32.h:46
Botan::SHA_256::output_length
size_t output_length() const override
Definition: sha2_32.h:49
Botan::SHA_256::name
std::string name() const override
Definition: sha2_32.h:48
Botan::SHA_256::SHA_256
SHA_256()
Definition: sha2_32.h:57
Botan::SHA_256::clone
HashFunction * clone() const override
Definition: sha2_32.h:50
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