Update for latest nazarautils update
This commit is contained in:
@@ -46,34 +46,34 @@ namespace Nz
|
||||
switch (type)
|
||||
{
|
||||
case HashType::Fletcher16:
|
||||
return std::make_unique<Fletcher16Hash>();
|
||||
return std::make_unique<Fletcher16Hasher>();
|
||||
|
||||
case HashType::CRC32:
|
||||
return std::make_unique<CRC32Hash>();
|
||||
return std::make_unique<CRC32Hasher>();
|
||||
|
||||
case HashType::CRC64:
|
||||
return std::make_unique<CRC64Hash>();
|
||||
return std::make_unique<CRC64Hasher>();
|
||||
|
||||
case HashType::MD5:
|
||||
return std::make_unique<MD5Hash>();
|
||||
return std::make_unique<MD5Hasher>();
|
||||
|
||||
case HashType::SHA1:
|
||||
return std::make_unique<SHA1Hash>();
|
||||
return std::make_unique<SHA1Hasher>();
|
||||
|
||||
case HashType::SHA224:
|
||||
return std::make_unique<SHA224Hash>();
|
||||
return std::make_unique<SHA224Hasher>();
|
||||
|
||||
case HashType::SHA256:
|
||||
return std::make_unique<SHA256Hash>();
|
||||
return std::make_unique<SHA256Hasher>();
|
||||
|
||||
case HashType::SHA384:
|
||||
return std::make_unique<SHA384Hash>();
|
||||
return std::make_unique<SHA384Hasher>();
|
||||
|
||||
case HashType::SHA512:
|
||||
return std::make_unique<SHA512Hash>();
|
||||
return std::make_unique<SHA512Hasher>();
|
||||
|
||||
case HashType::Whirlpool:
|
||||
return std::make_unique<WhirlpoolHash>();
|
||||
return std::make_unique<WhirlpoolHasher>();
|
||||
}
|
||||
|
||||
NazaraInternalError("Hash type not handled (0x" + NumberToString(UnderlyingCast(type), 16) + ')');
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
CRC32Hash::CRC32Hash(UInt32 polynomial)
|
||||
CRC32Hasher::CRC32Hasher(UInt32 polynomial)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
CRC32Hash::~CRC32Hash()
|
||||
CRC32Hasher::~CRC32Hasher()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -92,18 +92,18 @@ namespace Nz
|
||||
delete[] m_table;
|
||||
}
|
||||
|
||||
void CRC32Hash::Append(const UInt8* data, std::size_t len)
|
||||
void CRC32Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
while (len--)
|
||||
m_crc = m_table[(m_crc ^ *data++) & 0xFF] ^ (m_crc >> 8);
|
||||
}
|
||||
|
||||
void CRC32Hash::Begin()
|
||||
void CRC32Hasher::Begin()
|
||||
{
|
||||
m_crc = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
ByteArray CRC32Hash::End()
|
||||
ByteArray CRC32Hasher::End()
|
||||
{
|
||||
m_crc ^= 0xFFFFFFFF;
|
||||
|
||||
@@ -114,12 +114,12 @@ namespace Nz
|
||||
return ByteArray(reinterpret_cast<UInt8*>(&m_crc), 4);
|
||||
}
|
||||
|
||||
std::size_t CRC32Hash::GetDigestLength() const
|
||||
std::size_t CRC32Hasher::GetDigestLength() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
const char* CRC32Hash::GetHashName() const
|
||||
const char* CRC32Hasher::GetHashName() const
|
||||
{
|
||||
return "CRC32";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
void CRC64Hash::Append(const UInt8* data, std::size_t len)
|
||||
void CRC64Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -86,12 +86,12 @@ namespace Nz
|
||||
m_crc = (m_crc << 8) ^ crc64_table[((m_crc >> 56) ^ *data++) & 0xFF];
|
||||
}
|
||||
|
||||
void CRC64Hash::Begin()
|
||||
void CRC64Hasher::Begin()
|
||||
{
|
||||
m_crc = 0;
|
||||
}
|
||||
|
||||
ByteArray CRC64Hash::End()
|
||||
ByteArray CRC64Hasher::End()
|
||||
{
|
||||
#ifdef NAZARA_LITTLE_ENDIAN
|
||||
SwapBytes(&m_crc, sizeof(UInt64));
|
||||
@@ -100,12 +100,12 @@ namespace Nz
|
||||
return ByteArray(reinterpret_cast<UInt8*>(&m_crc), 8);
|
||||
}
|
||||
|
||||
std::size_t CRC64Hash::GetDigestLength() const
|
||||
std::size_t CRC64Hasher::GetDigestLength() const
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
const char* CRC64Hash::GetHashName() const
|
||||
const char* CRC64Hasher::GetHashName() const
|
||||
{
|
||||
return "CRC64";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void Fletcher16Hash::Append(const UInt8* data, std::size_t len)
|
||||
void Fletcher16Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
while (len > 0)
|
||||
{
|
||||
@@ -27,13 +27,13 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void Fletcher16Hash::Begin()
|
||||
void Fletcher16Hasher::Begin()
|
||||
{
|
||||
m_sum1 = 0xFF;
|
||||
m_sum2 = 0xFF;
|
||||
}
|
||||
|
||||
ByteArray Fletcher16Hash::End()
|
||||
ByteArray Fletcher16Hasher::End()
|
||||
{
|
||||
m_sum1 = (m_sum1 & 0xFF) + (m_sum1 >> 8);
|
||||
m_sum2 = (m_sum2 & 0xFF) + (m_sum2 >> 8);
|
||||
@@ -47,12 +47,12 @@ namespace Nz
|
||||
return ByteArray(reinterpret_cast<UInt8*>(&fletcher), 2);
|
||||
}
|
||||
|
||||
std::size_t Fletcher16Hash::GetDigestLength() const
|
||||
std::size_t Fletcher16Hasher::GetDigestLength() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
const char* Fletcher16Hash::GetHashName() const
|
||||
const char* Fletcher16Hasher::GetHashName() const
|
||||
{
|
||||
return "Fletcher16";
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void MD5Hash::Append(const UInt8* data, std::size_t len)
|
||||
void MD5Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
const UInt8 *p = data;
|
||||
std::size_t left = len;
|
||||
@@ -138,7 +138,7 @@ namespace Nz
|
||||
std::memcpy(m_buf, p, left);
|
||||
}
|
||||
|
||||
void MD5Hash::Begin()
|
||||
void MD5Hasher::Begin()
|
||||
{
|
||||
m_count[0] = m_count[1] = 0;
|
||||
m_abcd[0] = 0x67452301;
|
||||
@@ -147,7 +147,7 @@ namespace Nz
|
||||
m_abcd[3] = 0x10325476;
|
||||
}
|
||||
|
||||
ByteArray MD5Hash::End()
|
||||
ByteArray MD5Hasher::End()
|
||||
{
|
||||
static const unsigned char pad[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -174,17 +174,17 @@ namespace Nz
|
||||
return ByteArray(&digest[0], 16);
|
||||
}
|
||||
|
||||
std::size_t MD5Hash::GetDigestLength() const
|
||||
std::size_t MD5Hasher::GetDigestLength() const
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
const char* MD5Hash::GetHashName() const
|
||||
const char* MD5Hasher::GetHashName() const
|
||||
{
|
||||
return "MD5";
|
||||
}
|
||||
|
||||
void MD5Hash::md5_process(const UInt8* data)
|
||||
void MD5Hasher::md5_process(const UInt8* data)
|
||||
{
|
||||
UInt32 a = m_abcd[0];
|
||||
UInt32 b = m_abcd[1];
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SHA1Hash::SHA1Hash()
|
||||
SHA1Hasher::SHA1Hasher()
|
||||
{
|
||||
m_state = new SHA_CTX;
|
||||
}
|
||||
|
||||
SHA1Hash::~SHA1Hash()
|
||||
SHA1Hasher::~SHA1Hasher()
|
||||
{
|
||||
delete m_state;
|
||||
}
|
||||
|
||||
void SHA1Hash::Append(const UInt8* data, std::size_t len)
|
||||
void SHA1Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
SHA1_Update(m_state, data, len);
|
||||
}
|
||||
|
||||
void SHA1Hash::Begin()
|
||||
void SHA1Hasher::Begin()
|
||||
{
|
||||
SHA1_Init(m_state);
|
||||
}
|
||||
|
||||
ByteArray SHA1Hash::End()
|
||||
ByteArray SHA1Hasher::End()
|
||||
{
|
||||
UInt8 digest[SHA1_DIGEST_LENGTH];
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Nz
|
||||
return ByteArray(digest, SHA1_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
std::size_t SHA1Hash::GetDigestLength() const
|
||||
std::size_t SHA1Hasher::GetDigestLength() const
|
||||
{
|
||||
return SHA1_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
const char* SHA1Hash::GetHashName() const
|
||||
const char* SHA1Hasher::GetHashName() const
|
||||
{
|
||||
return "SHA1";
|
||||
}
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SHA224Hash::SHA224Hash()
|
||||
SHA224Hasher::SHA224Hasher()
|
||||
{
|
||||
m_state = new SHA_CTX;
|
||||
}
|
||||
|
||||
SHA224Hash::~SHA224Hash()
|
||||
SHA224Hasher::~SHA224Hasher()
|
||||
{
|
||||
delete m_state;
|
||||
}
|
||||
|
||||
void SHA224Hash::Append(const UInt8* data, std::size_t len)
|
||||
void SHA224Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
SHA224_Update(m_state, data, len);
|
||||
}
|
||||
|
||||
void SHA224Hash::Begin()
|
||||
void SHA224Hasher::Begin()
|
||||
{
|
||||
SHA224_Init(m_state);
|
||||
}
|
||||
|
||||
ByteArray SHA224Hash::End()
|
||||
ByteArray SHA224Hasher::End()
|
||||
{
|
||||
UInt8 digest[SHA224_DIGEST_LENGTH];
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Nz
|
||||
return ByteArray(digest, SHA224_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
std::size_t SHA224Hash::GetDigestLength() const
|
||||
std::size_t SHA224Hasher::GetDigestLength() const
|
||||
{
|
||||
return SHA224_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
const char* SHA224Hash::GetHashName() const
|
||||
const char* SHA224Hasher::GetHashName() const
|
||||
{
|
||||
return "SHA224";
|
||||
}
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SHA256Hash::SHA256Hash()
|
||||
SHA256Hasher::SHA256Hasher()
|
||||
{
|
||||
m_state = new SHA_CTX;
|
||||
}
|
||||
|
||||
SHA256Hash::~SHA256Hash()
|
||||
SHA256Hasher::~SHA256Hasher()
|
||||
{
|
||||
delete m_state;
|
||||
}
|
||||
|
||||
void SHA256Hash::Append(const UInt8* data, std::size_t len)
|
||||
void SHA256Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
SHA256_Update(m_state, data, len);
|
||||
}
|
||||
|
||||
void SHA256Hash::Begin()
|
||||
void SHA256Hasher::Begin()
|
||||
{
|
||||
SHA256_Init(m_state);
|
||||
}
|
||||
|
||||
ByteArray SHA256Hash::End()
|
||||
ByteArray SHA256Hasher::End()
|
||||
{
|
||||
UInt8 digest[SHA256_DIGEST_LENGTH];
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Nz
|
||||
return ByteArray(digest, SHA256_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
std::size_t SHA256Hash::GetDigestLength() const
|
||||
std::size_t SHA256Hasher::GetDigestLength() const
|
||||
{
|
||||
return SHA256_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
const char* SHA256Hash::GetHashName() const
|
||||
const char* SHA256Hasher::GetHashName() const
|
||||
{
|
||||
return "SHA256";
|
||||
}
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SHA384Hash::SHA384Hash()
|
||||
SHA384Hasher::SHA384Hasher()
|
||||
{
|
||||
m_state = new SHA_CTX;
|
||||
}
|
||||
|
||||
SHA384Hash::~SHA384Hash()
|
||||
SHA384Hasher::~SHA384Hasher()
|
||||
{
|
||||
delete m_state;
|
||||
}
|
||||
|
||||
void SHA384Hash::Append(const UInt8* data, std::size_t len)
|
||||
void SHA384Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
SHA384_Update(m_state, data, len);
|
||||
}
|
||||
|
||||
void SHA384Hash::Begin()
|
||||
void SHA384Hasher::Begin()
|
||||
{
|
||||
SHA384_Init(m_state);
|
||||
}
|
||||
|
||||
ByteArray SHA384Hash::End()
|
||||
ByteArray SHA384Hasher::End()
|
||||
{
|
||||
UInt8 digest[SHA384_DIGEST_LENGTH];
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Nz
|
||||
return ByteArray(digest, SHA384_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
std::size_t SHA384Hash::GetDigestLength() const
|
||||
std::size_t SHA384Hasher::GetDigestLength() const
|
||||
{
|
||||
return SHA384_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
const char* SHA384Hash::GetHashName() const
|
||||
const char* SHA384Hasher::GetHashName() const
|
||||
{
|
||||
return "SHA384";
|
||||
}
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
SHA512Hash::SHA512Hash()
|
||||
SHA512Hasher::SHA512Hasher()
|
||||
{
|
||||
m_state = new SHA_CTX;
|
||||
}
|
||||
|
||||
SHA512Hash::~SHA512Hash()
|
||||
SHA512Hasher::~SHA512Hasher()
|
||||
{
|
||||
delete m_state;
|
||||
}
|
||||
|
||||
void SHA512Hash::Append(const UInt8* data, std::size_t len)
|
||||
void SHA512Hasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
SHA512_Update(m_state, data, len);
|
||||
}
|
||||
|
||||
void SHA512Hash::Begin()
|
||||
void SHA512Hasher::Begin()
|
||||
{
|
||||
SHA512_Init(m_state);
|
||||
}
|
||||
|
||||
ByteArray SHA512Hash::End()
|
||||
ByteArray SHA512Hasher::End()
|
||||
{
|
||||
UInt8 digest[SHA512_DIGEST_LENGTH];
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Nz
|
||||
return ByteArray(digest, SHA512_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
std::size_t SHA512Hash::GetDigestLength() const
|
||||
std::size_t SHA512Hasher::GetDigestLength() const
|
||||
{
|
||||
return SHA512_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
const char* SHA512Hash::GetHashName() const
|
||||
const char* SHA512Hasher::GetHashName() const
|
||||
{
|
||||
return "SHA512";
|
||||
}
|
||||
|
||||
@@ -626,7 +626,7 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
void WhirlpoolHash::Append(const UInt8* data, std::size_t len)
|
||||
void WhirlpoolHasher::Append(const UInt8* data, std::size_t len)
|
||||
{
|
||||
len *= 8; // Whirlpool works with bits
|
||||
|
||||
@@ -713,7 +713,7 @@ namespace Nz
|
||||
m_bufferPos = bufferPos;
|
||||
}
|
||||
|
||||
void WhirlpoolHash::Begin()
|
||||
void WhirlpoolHasher::Begin()
|
||||
{
|
||||
std::memset(m_bitLength, 0, 32);
|
||||
m_bufferBits = m_bufferPos = 0;
|
||||
@@ -722,7 +722,7 @@ namespace Nz
|
||||
m_hash[i] = 0L; // initial value
|
||||
}
|
||||
|
||||
ByteArray WhirlpoolHash::End()
|
||||
ByteArray WhirlpoolHasher::End()
|
||||
{
|
||||
UInt8 result[64];
|
||||
|
||||
@@ -775,18 +775,18 @@ namespace Nz
|
||||
return ByteArray(&result[0], 64);
|
||||
}
|
||||
|
||||
std::size_t WhirlpoolHash::GetDigestLength() const
|
||||
std::size_t WhirlpoolHasher::GetDigestLength() const
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
const char* WhirlpoolHash::GetHashName() const
|
||||
const char* WhirlpoolHasher::GetHashName() const
|
||||
{
|
||||
return "Whirlpool";
|
||||
}
|
||||
|
||||
|
||||
void WhirlpoolHash::ProcessBuffer()
|
||||
void WhirlpoolHasher::ProcessBuffer()
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user