4.48 beta

This commit is contained in:
Igor Pavlov
2007-06-26 00:00:00 +00:00
committed by Kornel Lesiński
parent 0b33f700a6
commit fd8b1d78b4
249 changed files with 3224 additions and 2157 deletions

View File

@@ -1,4 +1,4 @@
// 7z_AES.cpp
// 7zAES.cpp
#include "StdAfx.h"
@@ -8,9 +8,12 @@
#include "../../Common/StreamUtils.h"
#include "../AES/MyAES.h"
#include "../Hash/Sha256.h"
#include "7zAES.h"
#ifndef EXTRACT_ONLY
#include "../Hash/RandGen.h"
#endif
using namespace NWindows;
namespace NCrypto {
@@ -89,7 +92,8 @@ static CKeyInfoCache g_GlobalKeyCache(32);
static NSynchronization::CCriticalSection g_GlobalKeyCacheCriticalSection;
CBase::CBase():
_cachedKeys(16)
_cachedKeys(16),
_ivSize(0)
{
for (int i = 0; i < sizeof(_iv); i++)
_iv[i] = 0;
@@ -111,40 +115,31 @@ void CBase::CalculateDigest()
}
}
#ifndef EXTRACT_ONLY
/*
static void GetRandomData(Byte *data)
STDMETHODIMP CEncoder::ResetSalt()
{
// probably we don't need truly random.
// it's enough to prevent dictionary attack;
// but it gives some info about time when compressing
// was made.
UInt64 tempValue;
SYSTEMTIME systemTime;
FILETIME fileTime;
::GetSystemTime(&systemTime);
::SystemTimeToFileTime(&systemTime, &fileTime);
tempValue = *(const UInt64 *)&fileTime;
LARGE_INTEGER counter;
::QueryPerformanceCounter(&counter);
tempValue += *(const UInt64 *)&counter;
tempValue += (UInt64)(GetTickCount()) << 32;
*(UInt64 *)data = tempValue;
_key.SaltSize = 4;
g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
return S_OK;
}
*/
STDMETHODIMP CEncoder::ResetInitVector()
{
_ivSize = 8;
g_RandomGenerator.Generate(_iv, _ivSize);
return S_OK;
}
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
_key.Init();
for (UInt32 i = 0; i < sizeof(_iv); i++)
// _key.Init();
for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
_iv[i] = 0;
_key.SaltSize = 0;
// _key.SaltSize = 8;
// GetRandomData(_key.Salt);
int ivSize = 0;
UInt32 ivSize = _ivSize;
// _key.NumCyclesPower = 0x3F;
_key.NumCyclesPower = 18;
@@ -170,6 +165,14 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
return S_OK;
}
HRESULT CEncoder::CreateFilter()
{
_aesFilter = new CAES_CBC_Encoder;
return S_OK;
}
#endif
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
{
_key.Init();
@@ -229,12 +232,6 @@ STDMETHODIMP_(UInt32) CBaseCoder::Filter(Byte *data, UInt32 size)
return _aesFilter->Filter(data, size);
}
HRESULT CEncoder::CreateFilter()
{
_aesFilter = new CAES_CBC_Encoder;
return S_OK;
}
HRESULT CDecoder::CreateFilter()
{
_aesFilter = new CAES_CBC_Decoder;

View File

@@ -6,7 +6,7 @@
#include "Common/MyCom.h"
#include "Common/Types.h"
#include "Common/Buffer.h"
#include "Common/Vector.h"
#include "Common/MyVector.h"
#include "../../ICoder.h"
#include "../../IPassword.h"
@@ -55,7 +55,7 @@ class CBase
protected:
CKeyInfo _key;
Byte _iv[16];
// int _ivSize;
UInt32 _ivSize;
void CalculateDigest();
CBase();
};
@@ -80,17 +80,26 @@ public:
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
};
#ifndef EXTRACT_ONLY
class CEncoder:
public CBaseCoder,
public ICompressWriteCoderProperties
public ICompressWriteCoderProperties,
// public ICryptoResetSalt,
public ICryptoResetInitVector
{
virtual HRESULT CreateFilter();
public:
MY_UNKNOWN_IMP2(
MY_UNKNOWN_IMP3(
ICryptoSetPassword,
ICompressWriteCoderProperties)
ICompressWriteCoderProperties,
// ICryptoResetSalt,
ICryptoResetInitVector)
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
// STDMETHOD(ResetSalt)();
STDMETHOD(ResetInitVector)();
};
#endif
class CDecoder:
public CBaseCoder,