Botan 2.19.1
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
15
16namespace Botan {
17
18/**
19* SHA-224
20*/
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
40 };
41
42/**
43* SHA-256
44*/
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
91 };
92
93}
94
95#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
size_t output_length() const override
Definition: sha2_32.h:25
HashFunction * clone() const override
Definition: sha2_32.h:26
std::string name() const override
Definition: sha2_32.h:24
size_t output_length() const override
Definition: sha2_32.h:49
std::string name() const override
Definition: sha2_32.h:48
HashFunction * clone() const override
Definition: sha2_32.h:50
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