summaryrefslogtreecommitdiff
path: root/sha.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
committerJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
commit48809d4e85c125814425c621d8d0d89f95405924 (patch)
tree1010fd16c4b1199f3d27dd726dda241a2bd29f83 /sha.h
parent025337a94aceb75d188149db70c2094673772816 (diff)
downloadcryptopp-git-48809d4e85c125814425c621d8d0d89f95405924.tar.gz
CRYPTOPP 5.6.3 RC6 checkin
Diffstat (limited to 'sha.h')
-rw-r--r--sha.h130
1 files changed, 67 insertions, 63 deletions
diff --git a/sha.h b/sha.h
index 679081e8..85d21c41 100644
--- a/sha.h
+++ b/sha.h
@@ -1,63 +1,67 @@
-#ifndef CRYPTOPP_SHA_H
-#define CRYPTOPP_SHA_H
-
-#include "iterhash.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-/// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a>
-class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
-{
-public:
- static void CRYPTOPP_API InitState(HashWordType *state);
- static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
- static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
-};
-
-typedef SHA1 SHA; // for backwards compatibility
-
-//! implements the SHA-256 standard
-class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, true>
-{
-public:
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
- size_t HashMultipleBlocks(const word32 *input, size_t length);
-#endif
- static void CRYPTOPP_API InitState(HashWordType *state);
- static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
- static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
-};
-
-//! implements the SHA-224 standard
-class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, true>
-{
-public:
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)
- size_t HashMultipleBlocks(const word32 *input, size_t length);
-#endif
- static void CRYPTOPP_API InitState(HashWordType *state);
- static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
- static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
-};
-
-//! implements the SHA-512 standard
-class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, CRYPTOPP_BOOL_X86>
-{
-public:
- static void CRYPTOPP_API InitState(HashWordType *state);
- static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
- static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
-};
-
-//! implements the SHA-384 standard
-class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, CRYPTOPP_BOOL_X86>
-{
-public:
- static void CRYPTOPP_API InitState(HashWordType *state);
- static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
- static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
-};
-
-NAMESPACE_END
-
-#endif
+#ifndef CRYPTOPP_SHA_H
+#define CRYPTOPP_SHA_H
+
+#include "config.h"
+#include "iterhash.h"
+#include "secblock.h"
+
+#define SHA_BOOL_ALIGN (CRYPTOPP_BOOL_ALIGN || CRYPTOPP_BOOL_ALIGN16)
+
+NAMESPACE_BEGIN(CryptoPP)
+
+/// <a href="http://www.weidai.com/scan-mirror/md.html#SHA-1">SHA-1</a>
+class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 20, SHA1>
+{
+public:
+ static void CRYPTOPP_API InitState(HashWordType *state);
+ static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
+ static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";}
+};
+
+typedef SHA1 SHA; // for backwards compatibility
+
+//! implements the SHA-256 standard
+class CRYPTOPP_DLL SHA256 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA256, 32, SHA_BOOL_ALIGN>
+{
+public:
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ size_t HashMultipleBlocks(const word32 *input, size_t length);
+#endif
+ static void CRYPTOPP_API InitState(HashWordType *state);
+ static void CRYPTOPP_API Transform(word32 *digest, const word32 *data);
+ static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-256";}
+};
+
+//! implements the SHA-224 standard
+class CRYPTOPP_DLL SHA224 : public IteratedHashWithStaticTransform<word32, BigEndian, 64, 32, SHA224, 28, SHA_BOOL_ALIGN>
+{
+public:
+#if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE) || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_SHA_ASM)
+ size_t HashMultipleBlocks(const word32 *input, size_t length);
+#endif
+ static void CRYPTOPP_API InitState(HashWordType *state);
+ static void CRYPTOPP_API Transform(word32 *digest, const word32 *data) {SHA256::Transform(digest, data);}
+ static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-224";}
+};
+
+//! implements the SHA-512 standard
+class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, SHA_BOOL_ALIGN>
+{
+public:
+ static void CRYPTOPP_API InitState(HashWordType *state);
+ static void CRYPTOPP_API Transform(word64 *digest, const word64 *data);
+ static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-512";}
+};
+
+//! implements the SHA-384 standard
+class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, SHA_BOOL_ALIGN>
+{
+public:
+ static void CRYPTOPP_API InitState(HashWordType *state);
+ static void CRYPTOPP_API Transform(word64 *digest, const word64 *data) {SHA512::Transform(digest, data);}
+ static const char * CRYPTOPP_API StaticAlgorithmName() {return "SHA-384";}
+};
+
+NAMESPACE_END
+
+#endif