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 /*! \warning HAVAL with 128-bit or 160-bit output is considered insecure, and should not be used
    00010         unless you absolutely need it for compatibility. */
    00011 class HAVAL : public IteratedHash<word32, LittleEndian, 128>
    00012 {
    00013 public:
    00014         enum {DIGESTSIZE = 32, HAVAL_VERSION = 1};
    00015
    00016         /// digestSize can be 16, 20, 24, 28, or 32 (Default=32)<br>
    00017         /// pass can be 3, 4 or 5 (Default=3)
    00018         HAVAL(unsigned int digestSize=DIGESTSIZE, unsigned int passes=3);
    00019         void TruncatedFinal(byte *hash, unsigned int size);
    00020         unsigned int DigestSize() const {return digestSize;}
    00021
    00022         static const char * StaticAlgorithmName() {return "HAVAL";}
    00023         std::string AlgorithmName() const {return std::string("HAVAL(") + IntToString(digestSize) + "," + IntToString(pass) + ")";}
    00024
    00025 protected:
    00026         static const unsigned int wi2[32], wi3[32], wi4[32], wi5[32];
    00027         static const word32 mc2[32], mc3[32], mc4[32], mc5[32];
    00028
    00029         void Init();
    00030         void Tailor(unsigned int FPTLEN);
    00031         void HashEndianCorrectedBlock(const word32 *in);
    00032
    00033         const unsigned int digestSize, pass;
    00034 };
    00035
    00036 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 3 passes
    00037 class HAVAL3 : public HAVAL
    00038 {
    00039 public:
    00040         HAVAL3(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 3) {}
    00041         static void Transform(word32 *buf, const word32 *in);
    00042 };
    00043
    00044 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 4 passes
    00045 class HAVAL4 : public HAVAL
    00046 {
    00047 public:
    00048         HAVAL4(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 4) {}
    00049         static void Transform(word32 *buf, const word32 *in);
    00050 };
    00051
    00052 /// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 5 passes
    00053 class HAVAL5 : public HAVAL
    00054 {
    00055 public:
    00056         HAVAL5(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 5) {}
    00057         static void Transform(word32 *buf, const word32 *in);
    00058 };
    00059
    00060 NAMESPACE_END
    00061
    00062 #endif