00001 #ifndef CRYPTOPP_HAVAL_H
00002 #define CRYPTOPP_HAVAL_H
00003
00004 #include "iterhash.h"
00005
00006 NAMESPACE_BEGIN(CryptoPP)
00007
00008
00009
00010
00011 class HAVAL : public IteratedHash<word32, LittleEndian, 128>
00012 {
00013 public:
00014 enum {HAVAL_VERSION = 1};
00015 CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
00016
00017
00018
00019 HAVAL(unsigned int digestSize=DIGESTSIZE, unsigned int passes=3);
00020 void TruncatedFinal(byte *hash, size_t size);
00021 unsigned int DigestSize() const {return digestSize;}
00022
00023 static const char * StaticAlgorithmName() {return "HAVAL";}
00024 std::string AlgorithmName() const {return std::string("HAVAL(") + IntToString(digestSize) + "," + IntToString(pass) + ")";}
00025
00026 protected:
00027 static const unsigned int wi2[32], wi3[32], wi4[32], wi5[32];
00028 static const word32 mc2[32], mc3[32], mc4[32], mc5[32];
00029
00030 void Init();
00031 void Tailor(unsigned int FPTLEN);
00032 void HashEndianCorrectedBlock(const word32 *in);
00033
00034 const unsigned int digestSize, pass;
00035 };
00036
00037
00038 class HAVAL3 : public HAVAL
00039 {
00040 public:
00041 HAVAL3(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 3) {}
00042 static void Transform(word32 *buf, const word32 *in);
00043 };
00044
00045
00046 class HAVAL4 : public HAVAL
00047 {
00048 public:
00049 HAVAL4(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 4) {}
00050 static void Transform(word32 *buf, const word32 *in);
00051 };
00052
00053
00054 class HAVAL5 : public HAVAL
00055 {
00056 public:
00057 HAVAL5(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 5) {}
00058 static void Transform(word32 *buf, const word32 *in);
00059 };
00060
00061 NAMESPACE_END
00062
00063 #endif