1
#ifndef CRYPTOPP_HAVAL_H
2
#define CRYPTOPP_HAVAL_H
6
NAMESPACE_BEGIN(CryptoPP)
8
/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a>
9
/*! \warning HAVAL with 128-bit or 160-bit output is considered insecure, and should not be used
10
unless you absolutely need it for compatibility. */
11
class HAVAL : public IteratedHash<word32, LittleEndian, 128>
14
enum {DIGESTSIZE = 32, HAVAL_VERSION = 1};
16
/// digestSize can be 16, 20, 24, 28, or 32 (Default=32)<br>
17
/// pass can be 3, 4 or 5 (Default=3)
18
HAVAL(unsigned int digestSize=DIGESTSIZE, unsigned int passes=3);
19
void TruncatedFinal(byte *hash, size_t size);
20
unsigned int DigestSize() const {return digestSize;}
22
static const char * StaticAlgorithmName() {return "HAVAL";}
23
std::string AlgorithmName() const {return std::string("HAVAL(") + IntToString(digestSize) + "," + IntToString(pass) + ")";}
26
static const unsigned int wi2[32], wi3[32], wi4[32], wi5[32];
27
static const word32 mc2[32], mc3[32], mc4[32], mc5[32];
30
void Tailor(unsigned int FPTLEN);
31
void HashEndianCorrectedBlock(const word32 *in);
33
const unsigned int digestSize, pass;
36
/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 3 passes
37
class HAVAL3 : public HAVAL
40
HAVAL3(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 3) {}
41
static void Transform(word32 *buf, const word32 *in);
44
/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 4 passes
45
class HAVAL4 : public HAVAL
48
HAVAL4(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 4) {}
49
static void Transform(word32 *buf, const word32 *in);
52
/// <a href="http://www.weidai.com/scan-mirror/md.html#HAVAL">HAVAL</a> with 5 passes
53
class HAVAL5 : public HAVAL
56
HAVAL5(unsigned int digestSize=DIGESTSIZE) : HAVAL(digestSize, 5) {}
57
static void Transform(word32 *buf, const word32 *in);