Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound 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 protected:
    00021         static const unsigned int wi2[32], wi3[32], wi4[32], wi5[32];
    00022         static const word32 mc2[32], mc3[32], mc4[32], mc5[32];
    00023
    00024         void Init();
    00025         void Tailor(unsigned int FPTLEN);
    00026         void vTransform(const word32 *in);
    00027
    00028         const unsigned int digestSize, pass;
    00029 };
    00030
    00031 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 3 passes
    00032 class HAVAL3 : public HAVAL
    00033 {
    00034 public:
    00035         HAVAL3(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 3) {}
    00036         static void Transform(word32 *buf, const word32 *in);
    00037 };
    00038
    00039 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 4 passes
    00040 class HAVAL4 : public HAVAL
    00041 {
    00042 public:
    00043         HAVAL4(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 4) {}
    00044         static void Transform(word32 *buf, const word32 *in);
    00045 };
    00046
    00047 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 5 passes
    00048 class HAVAL5 : public HAVAL
    00049 {
    00050 public:
    00051         HAVAL5(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 5) {}
    00052         static void Transform(word32 *buf, const word32 *in);
    00053 };
    00054
    00055 NAMESPACE_END
    00056
    00057 #endif