4.50 beta

This commit is contained in:
Igor Pavlov
2007-07-24 00:00:00 +00:00
committed by Kornel Lesiński
parent 7038848692
commit 980e181dcc
104 changed files with 1419 additions and 4952 deletions

View File

@@ -1,12 +1,11 @@
// RarAES.cpp
// This code is based on UnRar sources
// Note: you must include Crypto/AES/MyAES.cpp to project to initialize AES tables
#include "StdAfx.h"
#include "RarAES.h"
#include "../../Common/MethodId.h"
#include "../Hash/Sha1.h"
#include "../AES/MyAES.h"
namespace NCrypto {
namespace NRar29 {
@@ -77,19 +76,14 @@ STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
STDMETHODIMP CDecoder::Init()
{
Calculate();
if (!_aesFilter)
_aesFilter = new CAES_CBC_Decoder;
CMyComPtr<ICryptoProperties> cp;
RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
RINOK(cp->SetKey(aesKey, 16));
RINOK(cp->SetInitVector(aesInit, 16));
_aesFilter->Init();
AesSetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize);
AesCbcInit(&Aes, aesInit);
return S_OK;
}
STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
{
return _aesFilter->Filter(data, size);
return AesCbcDecode(&Aes, data, size);
}
void CDecoder::Calculate()

View File

@@ -10,9 +10,16 @@
#include "../../ICoder.h"
#include "../../IPassword.h"
extern "C"
{
#include "../../../../C/Crypto/Aes.h"
}
namespace NCrypto {
namespace NRar29 {
const kRarAesKeySize = 16;
class CDecoder:
public ICompressFilter,
public ICompressSetDecoderProperties2,
@@ -22,11 +29,11 @@ class CDecoder:
Byte _salt[8];
bool _thereIsSalt;
CByteBuffer buffer;
Byte aesKey[16];
Byte aesInit[16];
Byte aesKey[kRarAesKeySize];
Byte aesInit[AES_BLOCK_SIZE];
bool _needCalculate;
CMyComPtr<ICompressFilter> _aesFilter;
CAesCbc Aes;
bool _rar350Mode;