This commit is contained in:
Igor Pavlov
2021-07-22 23:00:14 +01:00
committed by Kornel
parent 4a960640a3
commit 585698650f
619 changed files with 34904 additions and 10859 deletions

View File

@@ -1,7 +1,7 @@
// Crypto/Sha1.h
// Crypto/Sha1Cls.h
#ifndef __CRYPTO_SHA1_H
#define __CRYPTO_SHA1_H
#ifndef __CRYPTO_SHA1_CLS_H
#define __CRYPTO_SHA1_CLS_H
#include "../../../C/Sha1.h"
@@ -14,35 +14,21 @@ const unsigned kNumDigestWords = SHA1_NUM_DIGEST_WORDS;
const unsigned kBlockSize = SHA1_BLOCK_SIZE;
const unsigned kDigestSize = SHA1_DIGEST_SIZE;
class CContextBase
class CContext
{
protected:
CSha1 _s;
public:
void Init() throw() { Sha1_Init(&_s); }
void GetBlockDigest(const UInt32 *blockData, UInt32 *destDigest) throw() { Sha1_GetBlockDigest(&_s, blockData, destDigest); }
};
class CContext: public CContextBase
{
public:
void Update(const Byte *data, size_t size) throw() { Sha1_Update(&_s, data, size); }
void UpdateRar(Byte *data, size_t size /* , bool rar350Mode */) throw() { Sha1_Update_Rar(&_s, data, size /* , rar350Mode ? 1 : 0 */); }
void Final(Byte *digest) throw() { Sha1_Final(&_s, digest); }
};
class CContext32: public CContextBase
{
public:
void Update(const UInt32 *data, size_t size) throw() { Sha1_32_Update(&_s, data, size); }
void Final(UInt32 *digest) throw() { Sha1_32_Final(&_s, digest); }
/* PrepareBlock can be used only when size <= 13. size in Words
_buffer must be empty (_count & 0xF) == 0) */
void PrepareBlock(UInt32 *block, unsigned size) const throw()
void PrepareBlock(Byte *block, unsigned size) const throw()
{
Sha1_32_PrepareBlock(&_s, block, size);
Sha1_PrepareBlock(&_s, block, size);
}
void GetBlockDigest(const Byte *blockData, Byte *destDigest) const throw()
{
Sha1_GetBlockDigest(&_s, blockData, destDigest);
}
};