blob: e157fd6570381e6d4ce2e991fc90c817071bf226 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* SHA-{224,256}
* (C) 1999-2008 Jack Lloyd
* 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
#ifndef BOTAN_SHA_256_H__
#define BOTAN_SHA_256_H__
#include <botan/mdx_hash.h>
namespace Botan {
/*
* SHA-{224,256} Base
*/
class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction
{
protected:
void clear();
SHA_224_256_BASE(u32bit out) :
MDx_HashFunction(out, 64, true, true) { clear(); }
SecureVector<u32bit, 64> W;
SecureVector<u32bit, 8> digest;
private:
void compress_n(const byte[], u32bit blocks);
void copy_out(byte[]);
};
/*
* SHA-224
*/
class BOTAN_DLL SHA_224 : public SHA_224_256_BASE
{
public:
void clear();
std::string name() const { return "SHA-224"; }
HashFunction* clone() const { return new SHA_224; }
SHA_224() : SHA_224_256_BASE(28) { clear(); }
};
/*
* SHA-256
*/
class BOTAN_DLL SHA_256 : public SHA_224_256_BASE
{
public:
void clear();
std::string name() const { return "SHA-256"; }
HashFunction* clone() const { return new SHA_256; }
SHA_256() : SHA_224_256_BASE(32) { clear (); }
};
}
#endif
|