This commit is contained in:
Igor Pavlov
2016-05-20 00:00:00 +00:00
committed by Kornel Lesiński
parent 66ac98bb02
commit bec3b479dc
88 changed files with 972 additions and 753 deletions

View File

@@ -13,25 +13,25 @@ namespace NCrypto {
namespace NZip {
#define UPDATE_KEYS(b) { \
Key0 = CRC_UPDATE_BYTE(Key0, b); \
Key1 = (Key1 + (Key0 & 0xFF)) * 0x8088405 + 1; \
Key2 = CRC_UPDATE_BYTE(Key2, (Byte)(Key1 >> 24)); } \
key0 = CRC_UPDATE_BYTE(key0, b); \
key1 = (key1 + (key0 & 0xFF)) * 0x8088405 + 1; \
key2 = CRC_UPDATE_BYTE(key2, (Byte)(key1 >> 24)); } \
#define DECRYPT_BYTE_1 UInt32 temp = Key2 | 2;
#define DECRYPT_BYTE_1 UInt32 temp = key2 | 2;
#define DECRYPT_BYTE_2 ((Byte)((temp * (temp ^ 1)) >> 8))
STDMETHODIMP CCipher::CryptoSetPassword(const Byte *data, UInt32 size)
{
UInt32 Key0 = 0x12345678;
UInt32 Key1 = 0x23456789;
UInt32 Key2 = 0x34567890;
UInt32 key0 = 0x12345678;
UInt32 key1 = 0x23456789;
UInt32 key2 = 0x34567890;
for (UInt32 i = 0; i < size; i++)
UPDATE_KEYS(data[i]);
KeyMem0 = Key0;
KeyMem1 = Key1;
KeyMem2 = Key2;
KeyMem0 = key0;
KeyMem1 = key1;
KeyMem2 = key2;
return S_OK;
}
@@ -60,9 +60,9 @@ HRESULT CEncoder::WriteHeader_Check16(ISequentialOutStream *outStream, UInt16 cr
STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
{
UInt32 Key0 = this->Key0;
UInt32 Key1 = this->Key1;
UInt32 Key2 = this->Key2;
UInt32 key0 = this->Key0;
UInt32 key1 = this->Key1;
UInt32 key2 = this->Key2;
for (UInt32 i = 0; i < size; i++)
{
@@ -72,9 +72,9 @@ STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
UPDATE_KEYS(b);
}
this->Key0 = Key0;
this->Key1 = Key1;
this->Key2 = Key2;
this->Key0 = key0;
this->Key1 = key1;
this->Key2 = key2;
return size;
}
@@ -92,9 +92,9 @@ void CDecoder::Init_BeforeDecode()
STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
{
UInt32 Key0 = this->Key0;
UInt32 Key1 = this->Key1;
UInt32 Key2 = this->Key2;
UInt32 key0 = this->Key0;
UInt32 key1 = this->Key1;
UInt32 key2 = this->Key2;
for (UInt32 i = 0; i < size; i++)
{
@@ -104,9 +104,9 @@ STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
data[i] = b;
}
this->Key0 = Key0;
this->Key1 = Key1;
this->Key2 = Key2;
this->Key0 = key0;
this->Key1 = key1;
this->Key2 = key2;
return size;
}

View File

@@ -139,7 +139,6 @@ HRESULT CDecoder::Init_and_CheckPassword(bool &passwOK)
if (cert)
{
// how to filter rd, if ((rdSize & 0xF) != 0) ?
/*
if ((rdSize & 0x7) != 0)
return E_NOTIMPL;
}