mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-12 18:11:35 -06:00
4.45 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
d9666cf046
commit
a145bfc7cf
@@ -1,12 +1,12 @@
|
||||
// Crypto/RarAES/RarAES.h
|
||||
// RarAES.cpp
|
||||
// This code is based on UnRar sources
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "RarAES.h"
|
||||
#include "../../Common/MethodID.h"
|
||||
#include "../Hash/Sha1.h"
|
||||
|
||||
extern void GetCryptoFolderPrefix(TCHAR *path);
|
||||
#include "../AES/MyAES.h"
|
||||
|
||||
namespace NCrypto {
|
||||
namespace NRar29 {
|
||||
@@ -77,7 +77,8 @@ STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
|
||||
STDMETHODIMP CDecoder::Init()
|
||||
{
|
||||
Calculate();
|
||||
RINOK(CreateFilter());
|
||||
if (!_aesFilter)
|
||||
_aesFilter = new CAES_CBC_Decoder;
|
||||
CMyComPtr<ICryptoProperties> cp;
|
||||
RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
|
||||
RINOK(cp->SetKey(aesKey, 16));
|
||||
@@ -86,16 +87,6 @@ STDMETHODIMP CDecoder::Init()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDecoder::CreateFilter()
|
||||
{
|
||||
if (_aesFilter)
|
||||
return S_OK;
|
||||
TCHAR aesLibPath[MAX_PATH + 64];
|
||||
GetCryptoFolderPrefix(aesLibPath);
|
||||
lstrcat(aesLibPath, TEXT("AES.dll"));
|
||||
return _aesLib.LoadAndCreateFilter(aesLibPath, CLSID_CCrypto_AES_CBC_Decoder, &_aesFilter);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
|
||||
{
|
||||
return _aesFilter->Filter(data, size);
|
||||
@@ -152,36 +143,4 @@ void CDecoder::Calculate()
|
||||
_needCalculate = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
|
||||
ISequentialOutStream *outStream, UInt64 const *inSize,
|
||||
const UInt64 *outSize,ICompressProgressInfo *progress)
|
||||
{
|
||||
Calculate();
|
||||
TCHAR aesLibPath[MAX_PATH + 64];
|
||||
GetCryptoFolderPrefix(aesLibPath);
|
||||
lstrcat(aesLibPath, TEXT("AES.dll"));
|
||||
CCoderLibrary aesLib;
|
||||
CMyComPtr<ICompressCoder2> aesDecoder;
|
||||
RINOK(aesLib.LoadAndCreateCoder2(aesLibPath, CLSID_CCrypto_AES128_Decoder, &aesDecoder));
|
||||
|
||||
CSequentialInStreamImp *ivStreamSpec = new CSequentialInStreamImp;
|
||||
CMyComPtr<ISequentialInStream> ivStream(ivStreamSpec);
|
||||
ivStreamSpec->Init(aesInit, 16);
|
||||
|
||||
CSequentialInStreamImp *keyStreamSpec = new CSequentialInStreamImp;
|
||||
CMyComPtr<ISequentialInStream> keyStream(keyStreamSpec);
|
||||
keyStreamSpec->Init(aesKey, 16);
|
||||
|
||||
ISequentialInStream *inStreams[3] = { inStream, ivStream, keyStream };
|
||||
UInt64 ivSize = 16;
|
||||
UInt64 keySize = 16;
|
||||
const UInt64 *inSizes[3] = { inSize, &ivSize, &ivSize, };
|
||||
return aesDecoder->Code(inStreams, inSizes, 3,
|
||||
&outStream, &outSize, 1, progress);
|
||||
}
|
||||
*/
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
// Crypto/CRarAES/RarAES.h
|
||||
// RarAES.h
|
||||
|
||||
#ifndef __CRYPTO_RARAES_H
|
||||
#define __CRYPTO_RARAES_H
|
||||
|
||||
#include "Common/MyCom.h"
|
||||
#include "../../ICoder.h"
|
||||
#include "../../IPassword.h"
|
||||
#include "../../Archive/Common/CoderLoader.h"
|
||||
|
||||
#include "Common/Types.h"
|
||||
#include "Common/Buffer.h"
|
||||
|
||||
DEFINE_GUID(CLSID_CCrypto_AES_CBC_Decoder,
|
||||
0x23170F69, 0x40C1, 0x278B, 0x06, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
#include "../../ICoder.h"
|
||||
#include "../../IPassword.h"
|
||||
|
||||
namespace NCrypto {
|
||||
namespace NRar29 {
|
||||
@@ -30,13 +26,11 @@ class CDecoder:
|
||||
Byte aesInit[16];
|
||||
bool _needCalculate;
|
||||
|
||||
CCoderLibrary _aesLib;
|
||||
CMyComPtr<ICompressFilter> _aesFilter;
|
||||
|
||||
bool _rar350Mode;
|
||||
|
||||
void Calculate();
|
||||
HRESULT CreateFilter();
|
||||
|
||||
public:
|
||||
|
||||
@@ -45,6 +39,7 @@ public:
|
||||
ICompressSetDecoderProperties2)
|
||||
|
||||
STDMETHOD(Init)();
|
||||
|
||||
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
|
||||
|
||||
STDMETHOD(CryptoSetPassword)(const Byte *aData, UInt32 aSize);
|
||||
|
||||
Reference in New Issue
Block a user