Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

haval.h

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

Generated on Sat Jan 22 09:44:27 2005 for Crypto++ by  doxygen 1.4.0