summaryrefslogtreecommitdiff
path: root/cryptopp/crypto/haval.h
diff options
context:
space:
mode:
authorwatcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-04-21 14:14:52 +0000
committerwatcherhd <watcherhd@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-04-21 14:14:52 +0000
commitcb4a46e7fbe62d788e66ed6121c717a2d22a4d7c (patch)
tree30df260fdc5a1b5a7049c2f8cac8b7ef17513d6d /cryptopp/crypto/haval.h
parent19b6f534d2e784a1e120bf52c4aa07004798f473 (diff)
svn.miranda.im is moving to a new home!
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'cryptopp/crypto/haval.h')
-rw-r--r--cryptopp/crypto/haval.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/cryptopp/crypto/haval.h b/cryptopp/crypto/haval.h
new file mode 100644
index 0000000..4cd6db3
--- /dev/null
+++ b/cryptopp/crypto/haval.h
@@ -0,0 +1,63 @@
+#ifndef CRYPTOPP_HAVAL_H
+#define CRYPTOPP_HAVAL_H
+
+#include "iterhash.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a>
+/*! \warning HAVAL with 128-bit or 160-bit output is considered insecure, and should not be used
+ unless you absolutely need it for compatibility. */
+class HAVAL : public IteratedHash<word32, LittleEndian, 128>
+{
+public:
+ enum {HAVAL_VERSION = 1};
+ CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
+
+ /// digestSize can be 16, 20, 24, 28, or 32 (Default=32)<br>
+ /// pass can be 3, 4 or 5 (Default=3)
+ HAVAL(unsigned int digestSize=DIGESTSIZE, unsigned int passes=3);
+ void TruncatedFinal(byte *hash, size_t size);
+ unsigned int DigestSize() const {return digestSize;}
+
+ static const char * StaticAlgorithmName() {return "HAVAL";}
+ std::string AlgorithmName() const {return std::string("HAVAL(") + IntToString(digestSize) + "," + IntToString(pass) + ")";}
+
+protected:
+ static const unsigned int wi2[32], wi3[32], wi4[32], wi5[32];
+ static const word32 mc2[32], mc3[32], mc4[32], mc5[32];
+
+ void Init();
+ void Tailor(unsigned int FPTLEN);
+ void HashEndianCorrectedBlock(const word32 *in);
+
+ const unsigned int digestSize, pass;
+};
+
+/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 3 passes
+class HAVAL3 : public HAVAL
+{
+public:
+ HAVAL3(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 3) {}
+ static void Transform(word32 *buf, const word32 *in);
+};
+
+/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 4 passes
+class HAVAL4 : public HAVAL
+{
+public:
+ HAVAL4(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 4) {}
+ static void Transform(word32 *buf, const word32 *in);
+};
+
+/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 5 passes
+class HAVAL5 : public HAVAL
+{
+public:
+ HAVAL5(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 5) {}
+ static void Transform(word32 *buf, const word32 *in);
+};
+
+NAMESPACE_END
+
+#endif