aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/sha2/sha2_32.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-28 15:33:58 +0000
committerlloyd <[email protected]>2010-06-28 15:33:58 +0000
commit06cea953d28c7b372ccdb2765c57774e2799dd77 (patch)
tree8e51c688f6aec190a0f1d4ed5f700015dbb13c2a /src/hash/sha2/sha2_32.h
parent420bb86ee0722cb214378611d8b0ceffedfc5eba (diff)
For the SHA-2 classes, don't use inheritence to share a handful of
things, just share the compression function via an anon namespace member, and replicate the simple stuff like copy_out.
Diffstat (limited to 'src/hash/sha2/sha2_32.h')
-rw-r--r--src/hash/sha2/sha2_32.h47
1 files changed, 19 insertions, 28 deletions
diff --git a/src/hash/sha2/sha2_32.h b/src/hash/sha2/sha2_32.h
index e8e60d07c..71f0cff4b 100644
--- a/src/hash/sha2/sha2_32.h
+++ b/src/hash/sha2/sha2_32.h
@@ -1,61 +1,52 @@
/*
* SHA-{224,256}
-* (C) 1999-2008 Jack Lloyd
+* (C) 1999-2010 Jack Lloyd
* 2007 FlexSecure GmbH
*
* Distributed under the terms of the Botan license
*/
-#ifndef BOTAN_SHA_256_H__
-#define BOTAN_SHA_256_H__
+#ifndef BOTAN_SHA_224_256_H__
+#define BOTAN_SHA_224_256_H__
#include <botan/mdx_hash.h>
namespace Botan {
/**
-* Base class for the 32-bit SHA-2 hashes (SHA-224 and SHA-256)
-*/
-class BOTAN_DLL SHA_224_256_BASE : public MDx_HashFunction
- {
- protected:
- void clear();
-
- /**
- * @param out output size in bytes
- */
- 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
+class BOTAN_DLL SHA_224 : public MDx_HashFunction
{
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_224() : MDx_HashFunction(28, 64, true, true) { clear(); }
+ private:
+ void compress_n(const byte[], u32bit blocks);
+ void copy_out(byte[]);
+
+ SecureVector<u32bit, 64> W;
+ SecureVector<u32bit, 8> digest;
};
/**
* SHA-256
*/
-class BOTAN_DLL SHA_256 : public SHA_224_256_BASE
+class BOTAN_DLL SHA_256 : public MDx_HashFunction
{
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 (); }
+ SHA_256() : MDx_HashFunction(32, 64, true, true) { clear(); }
+ private:
+ void compress_n(const byte[], u32bit blocks);
+ void copy_out(byte[]);
+
+ SecureVector<u32bit, 64> W;
+ SecureVector<u32bit, 8> digest;
};
}