This commit is contained in:
Igor Pavlov
2010-10-04 00:00:00 +00:00
committed by Kornel Lesiński
parent 044e4bb741
commit 2eb60a0598
105 changed files with 868 additions and 466 deletions

View File

@@ -106,9 +106,9 @@ void CDecoder::Calculate()
unsigned i;
for (i = 0; i < kNumRounds; i++)
{
sha.Update(rawPassword, rawLength, _rar350Mode);
sha.UpdateRar(rawPassword, rawLength, _rar350Mode);
Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
sha.Update(pswNum, 3, _rar350Mode);
sha.UpdateRar(pswNum, 3, _rar350Mode);
if (i % (kNumRounds / 16) == 0)
{
NSha1::CContext shaTemp = sha;

View File

@@ -112,11 +112,29 @@ void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
block[curBufferPos++] = (UInt32)(lenInBits);
}
void CContext::Update(Byte *data, size_t size, bool rar350Mode)
void CContext::Update(const Byte *data, size_t size)
{
unsigned curBufferPos = _count2;
while (size--)
{
int pos = (int)(curBufferPos & 3);
if (pos == 0)
_buffer[curBufferPos >> 2] = 0;
_buffer[curBufferPos >> 2] |= ((UInt32)*data++) << (8 * (3 - pos));
if (++curBufferPos == kBlockSize)
{
curBufferPos = 0;
CContextBase::UpdateBlock(_buffer, false);
}
}
_count2 = curBufferPos;
}
void CContext::UpdateRar(Byte *data, size_t size, bool rar350Mode)
{
bool returnRes = false;
unsigned curBufferPos = _count2;
while (size-- > 0)
while (size--)
{
int pos = (int)(curBufferPos & 3);
if (pos == 0)
@@ -179,7 +197,7 @@ void CContext::Final(Byte *digest)
void CContext32::Update(const UInt32 *data, size_t size)
{
while (size-- > 0)
while (size--)
{
_buffer[_count2++] = *data++;
if (_count2 == kBlockSizeInWords)

View File

@@ -51,8 +51,8 @@ public:
class CContext: public CContextBase2
{
public:
void Update(Byte *data, size_t size, bool rar350Mode = false);
void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); }
void Update(const Byte *data, size_t size);
void UpdateRar(Byte *data, size_t size, bool rar350Mode);
void Final(Byte *digest);
};