mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-15 10:11:44 -06:00
4.25 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
47f4915611
commit
af1fe52701
@@ -119,32 +119,38 @@ void CDecoder::Calculate()
|
||||
rawLength += SALT_SIZE;
|
||||
}
|
||||
|
||||
hash_context c;
|
||||
hash_initial(&c);
|
||||
CSHA1 sha;
|
||||
sha.Init();
|
||||
|
||||
// seems rar reverts hash for sha.
|
||||
const int hashRounds = 0x40000;
|
||||
int i;
|
||||
for (i = 0; i < hashRounds; i++)
|
||||
{
|
||||
hash_process(&c, rawPassword, rawLength);
|
||||
sha.Update(rawPassword, rawLength);
|
||||
Byte pswNum[3];
|
||||
pswNum[0] = (Byte)i;
|
||||
pswNum[1] = (Byte)(i >> 8);
|
||||
pswNum[2] = (Byte)(i >> 16);
|
||||
hash_process(&c, pswNum, 3);
|
||||
sha.Update(pswNum, 3);
|
||||
if (i % (hashRounds / 16) == 0)
|
||||
{
|
||||
hash_context tempc = c;
|
||||
UInt32 digest[5];
|
||||
hash_final(&tempc, digest);
|
||||
aesInit[i / (hashRounds / 16)] = (Byte)digest[4];
|
||||
CSHA1 shaTemp = sha;
|
||||
Byte digest[20];
|
||||
shaTemp.Final(digest);
|
||||
aesInit[i / (hashRounds / 16)] = (Byte)digest[4 * 4 + 3];
|
||||
}
|
||||
}
|
||||
UInt32 digest[5];
|
||||
hash_final(&c, digest);
|
||||
/*
|
||||
// it's test message for sha
|
||||
const char *message = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
|
||||
sha.Update((const Byte *)message, strlen(message));
|
||||
*/
|
||||
Byte digest[20];
|
||||
sha.Final(digest);
|
||||
for (i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
aesKey[i * 4 + j] = (Byte)(digest[i] >> (j * 8));
|
||||
aesKey[i * 4 + j] = (digest[i * 4 + 3 - j]);
|
||||
}
|
||||
_needCalculate = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user