Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '7zip/Crypto/RarAES/RarAES.cpp')
-rwxr-xr-x7zip/Crypto/RarAES/RarAES.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/7zip/Crypto/RarAES/RarAES.cpp b/7zip/Crypto/RarAES/RarAES.cpp
index 827990af..16a48349 100755
--- a/7zip/Crypto/RarAES/RarAES.cpp
+++ b/7zip/Crypto/RarAES/RarAES.cpp
@@ -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;
}