RarAes.cpp (p7zip_15.14.1_src_all) | : | RarAes.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 14 | skipping to change at line 14 | |||
#include "RarAes.h" | #include "RarAes.h" | |||
#include "Sha1Cls.h" | #include "Sha1Cls.h" | |||
namespace NCrypto { | namespace NCrypto { | |||
namespace NRar3 { | namespace NRar3 { | |||
CDecoder::CDecoder(): | CDecoder::CDecoder(): | |||
CAesCbcDecoder(kAesKeySize), | CAesCbcDecoder(kAesKeySize), | |||
_thereIsSalt(false), | _thereIsSalt(false), | |||
_needCalc(true), | _needCalc(true) | |||
_rar350Mode(false) | // _rar350Mode(false) | |||
{ | { | |||
for (unsigned i = 0; i < sizeof(_salt); i++) | for (unsigned i = 0; i < sizeof(_salt); i++) | |||
_salt[i] = 0; | _salt[i] = 0; | |||
} | } | |||
HRESULT CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size) | HRESULT CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size) | |||
{ | { | |||
bool prev = _thereIsSalt; | bool prev = _thereIsSalt; | |||
_thereIsSalt = false; | _thereIsSalt = false; | |||
if (size == 0) | if (size == 0) | |||
skipping to change at line 114 | skipping to change at line 114 | |||
NSha1::CContext sha; | NSha1::CContext sha; | |||
sha.Init(); | sha.Init(); | |||
Byte digest[NSha1::kDigestSize]; | Byte digest[NSha1::kDigestSize]; | |||
// rar reverts hash for sha. | // rar reverts hash for sha. | |||
const UInt32 kNumRounds = ((UInt32)1 << 18); | const UInt32 kNumRounds = ((UInt32)1 << 18); | |||
UInt32 i; | UInt32 i; | |||
for (i = 0; i < kNumRounds; i++) | for (i = 0; i < kNumRounds; i++) | |||
{ | { | |||
sha.UpdateRar(buf, rawSize, _rar350Mode); | sha.UpdateRar(buf, rawSize /* , _rar350Mode */); | |||
Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) }; | Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) }; | |||
sha.UpdateRar(pswNum, 3, _rar350Mode); | sha.UpdateRar(pswNum, 3 /* , _rar350Mode */); | |||
if (i % (kNumRounds / 16) == 0) | if (i % (kNumRounds / 16) == 0) | |||
{ | { | |||
NSha1::CContext shaTemp = sha; | NSha1::CContext shaTemp = sha; | |||
shaTemp.Final(digest); | shaTemp.Final(digest); | |||
_iv[i / (kNumRounds / 16)] = (Byte)digest[4 * 4 + 3]; | _iv[i / (kNumRounds / 16)] = (Byte)digest[4 * 4 + 3]; | |||
} | } | |||
} | } | |||
sha.Final(digest); | sha.Final(digest); | |||
for (i = 0; i < 4; i++) | for (i = 0; i < 4; i++) | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added |