4.44 beta

This commit is contained in:
Igor Pavlov
2007-01-20 00:00:00 +00:00
committed by Kornel Lesiński
parent 804edc5756
commit d9666cf046
1331 changed files with 10535 additions and 13791 deletions

305
CPP/7zip/Crypto/7zAES/7zAES.cpp Executable file
View File

@@ -0,0 +1,305 @@
// 7z_AES.cpp
#include "StdAfx.h"
#include "Windows/Defs.h"
#include "Windows/Synchronization.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/StreamUtils.h"
#include "7zAES.h"
// #include "../../Hash/Common/CryptoHashInterface.h"
#ifdef CRYPTO_AES
#include "../AES/MyAES.h"
#endif
#include "../Hash/Sha256.h"
using namespace NWindows;
#ifndef CRYPTO_AES
extern HINSTANCE g_hInstance;
#endif
namespace NCrypto {
namespace NSevenZ {
bool CKeyInfo::IsEqualTo(const CKeyInfo &a) const
{
if (SaltSize != a.SaltSize || NumCyclesPower != a.NumCyclesPower)
return false;
for (UInt32 i = 0; i < SaltSize; i++)
if (Salt[i] != a.Salt[i])
return false;
return (Password == a.Password);
}
void CKeyInfo::CalculateDigest()
{
if (NumCyclesPower == 0x3F)
{
UInt32 pos;
for (pos = 0; pos < SaltSize; pos++)
Key[pos] = Salt[pos];
for (UInt32 i = 0; i < Password.GetCapacity() && pos < kKeySize; i++)
Key[pos++] = Password[i];
for (; pos < kKeySize; pos++)
Key[pos] = 0;
}
else
{
NCrypto::NSha256::CContext sha;
const UInt64 numRounds = UInt64(1) << (NumCyclesPower);
Byte temp[8] = { 0,0,0,0,0,0,0,0 };
for (UInt64 round = 0; round < numRounds; round++)
{
sha.Update(Salt, SaltSize);
sha.Update(Password, Password.GetCapacity());
sha.Update(temp, 8);
for (int i = 0; i < 8; i++)
if (++(temp[i]) != 0)
break;
}
sha.Final(Key);
}
}
bool CKeyInfoCache::Find(CKeyInfo &key)
{
for (int i = 0; i < Keys.Size(); i++)
{
const CKeyInfo &cached = Keys[i];
if (key.IsEqualTo(cached))
{
for (int j = 0; j < kKeySize; j++)
key.Key[j] = cached.Key[j];
if (i != 0)
{
Keys.Insert(0, cached);
Keys.Delete(i+1);
}
return true;
}
}
return false;
}
void CKeyInfoCache::Add(CKeyInfo &key)
{
if (Find(key))
return;
if (Keys.Size() >= Size)
Keys.DeleteBack();
Keys.Insert(0, key);
}
static CKeyInfoCache g_GlobalKeyCache(32);
static NSynchronization::CCriticalSection g_GlobalKeyCacheCriticalSection;
CBase::CBase():
_cachedKeys(16)
{
for (int i = 0; i < sizeof(_iv); i++)
_iv[i] = 0;
}
void CBase::CalculateDigest()
{
NSynchronization::CCriticalSectionLock lock(g_GlobalKeyCacheCriticalSection);
if (_cachedKeys.Find(_key))
g_GlobalKeyCache.Add(_key);
else
{
if (!g_GlobalKeyCache.Find(_key))
{
_key.CalculateDigest();
g_GlobalKeyCache.Add(_key);
}
_cachedKeys.Add(_key);
}
}
/*
static void GetRandomData(Byte *data)
{
// 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;
}
*/
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
_key.Init();
for (UInt32 i = 0; i < sizeof(_iv); i++)
_iv[i] = 0;
_key.SaltSize = 0;
// _key.SaltSize = 8;
// GetRandomData(_key.Salt);
int ivSize = 0;
// _key.NumCyclesPower = 0x3F;
_key.NumCyclesPower = 18;
Byte firstByte = (Byte)(_key.NumCyclesPower |
(((_key.SaltSize == 0) ? 0 : 1) << 7) |
(((ivSize == 0) ? 0 : 1) << 6));
RINOK(outStream->Write(&firstByte, 1, NULL));
if (_key.SaltSize == 0 && ivSize == 0)
return S_OK;
Byte saltSizeSpec = (Byte)((_key.SaltSize == 0) ? 0 : (_key.SaltSize - 1));
Byte ivSizeSpec = (Byte)((ivSize == 0) ? 0 : (ivSize - 1));
Byte secondByte = (Byte)(((saltSizeSpec) << 4) | ivSizeSpec);
RINOK(outStream->Write(&secondByte, 1, NULL));
if (_key.SaltSize > 0)
{
RINOK(WriteStream(outStream, _key.Salt, _key.SaltSize, NULL));
}
if (ivSize > 0)
{
RINOK(WriteStream(outStream, _iv, ivSize, NULL));
}
return S_OK;
}
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
{
_key.Init();
UInt32 i;
for (i = 0; i < sizeof(_iv); i++)
_iv[i] = 0;
if (size == 0)
return S_OK;
UInt32 pos = 0;
Byte firstByte = data[pos++];
_key.NumCyclesPower = firstByte & 0x3F;
if ((firstByte & 0xC0) == 0)
return S_OK;
_key.SaltSize = (firstByte >> 7) & 1;
UInt32 ivSize = (firstByte >> 6) & 1;
if (pos >= size)
return E_INVALIDARG;
Byte secondByte = data[pos++];
_key.SaltSize += (secondByte >> 4);
ivSize += (secondByte & 0x0F);
if (pos + _key.SaltSize + ivSize > size)
return E_INVALIDARG;
for (i = 0; i < _key.SaltSize; i++)
_key.Salt[i] = data[pos++];
for (i = 0; i < ivSize; i++)
_iv[i] = data[pos++];
return S_OK;
}
STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
{
_key.Password.SetCapacity(size);
memcpy(_key.Password, data, size);
return S_OK;
}
/*
static Byte *WideToRaw(const wchar_t *src, Byte *dest, int destSize=0x10000000)
{
for (int i = 0; i < destSize; i++, src++)
{
dest[i * 2] = (Byte)*src;
dest[i * 2 + 1]= (Byte)(*src >> 8);
if (*src == 0)
break;
}
return(dest);
}
*/
#ifndef CRYPTO_AES
bool GetAESLibPath(TCHAR *path)
{
TCHAR fullPath[MAX_PATH + 1];
if (::GetModuleFileName(g_hInstance, fullPath, MAX_PATH) == 0)
return false;
LPTSTR fileNamePointer;
DWORD needLength = ::GetFullPathName(fullPath, MAX_PATH + 1,
path, &fileNamePointer);
if (needLength == 0 || needLength >= MAX_PATH)
return false;
lstrcpy(fileNamePointer, TEXT("AES.dll"));
return true;
}
#endif
STDMETHODIMP CBaseCoder::Init()
{
CalculateDigest();
if (_aesFilter == 0)
{
RINOK(CreateFilter());
}
CMyComPtr<ICryptoProperties> cp;
RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
RINOK(cp->SetKey(_key.Key, sizeof(_key.Key)));
RINOK(cp->SetInitVector(_iv, sizeof(_iv)));
return S_OK;
}
STDMETHODIMP_(UInt32) CBaseCoder::Filter(Byte *data, UInt32 size)
{
return _aesFilter->Filter(data, size);
}
#ifndef CRYPTO_AES
HRESULT CBaseCoder::CreateFilterFromDLL(REFCLSID clsID)
{
if (!_aesLibrary)
{
TCHAR filePath[MAX_PATH + 2];
if (!GetAESLibPath(filePath))
return ::GetLastError();
return _aesLibrary.LoadAndCreateFilter(filePath, clsID, &_aesFilter);
}
return S_OK;
}
#endif
HRESULT CEncoder::CreateFilter()
{
#ifdef CRYPTO_AES
_aesFilter = new CAES_CBC_Encoder;
return S_OK;
#else
return CreateFilterFromDLL(CLSID_CCrypto_AES_CBC_Encoder);
#endif
}
HRESULT CDecoder::CreateFilter()
{
#ifdef CRYPTO_AES
_aesFilter = new CAES_CBC_Decoder;
return S_OK;
#else
return CreateFilterFromDLL(CLSID_CCrypto_AES_CBC_Decoder);
#endif
}
}}

245
CPP/7zip/Crypto/7zAES/7zAES.dsp Executable file
View File

@@ -0,0 +1,245 @@
# Microsoft Developer Studio Project File - Name="7zAES" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=7zAES - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "7zAES.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "7zAES.mak" CFG="7zAES - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "7zAES - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "7zAES - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "7zAES - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "7zAES_EXPORTS" /YX /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Codecs\7zAES.dll" /opt:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "7zAES_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Codecs\7zAES.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "7zAES - Win32 Release"
# Name "7zAES - Win32 Debug"
# Begin Group "Spec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Codec.def
# End Source File
# Begin Source File
SOURCE=.\DllExports.cpp
# End Source File
# Begin Source File
SOURCE=.\resource.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"StdAfx.h"
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\Alloc.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Alloc.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Vector.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Vector.h
# End Source File
# End Group
# Begin Group "7-Zip Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Common\StreamObjects.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamObjects.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringConvert.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringConvert.h
# End Source File
# End Group
# Begin Group "Windows"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Windows\DLL.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\DLL.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
# End Group
# Begin Group "Archive Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Archive\Common\CoderLoader.h
# End Source File
# End Group
# Begin Group "Hash"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Hash\RotateDefs.h
# End Source File
# Begin Source File
SOURCE=..\Hash\Sha256.cpp
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\Hash\Sha256.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\7zAES.cpp
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\7zAES.h
# End Source File
# End Target
# End Project

29
CPP/7zip/Crypto/7zAES/7zAES.dsw Executable file
View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "7zAES"=.\7zAES.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

122
CPP/7zip/Crypto/7zAES/7zAES.h Executable file
View File

@@ -0,0 +1,122 @@
// 7z_AES.h
#ifndef __CRYPTO_7Z_AES_H
#define __CRYPTO_7Z_AES_H
#include "Common/MyCom.h"
#include "Common/Types.h"
#include "Common/Buffer.h"
#include "Common/Vector.h"
#include "../../ICoder.h"
#include "../../IPassword.h"
#ifndef CRYPTO_AES
#include "../../Archive/Common/CoderLoader.h"
#endif
DEFINE_GUID(CLSID_CCrypto_AES_CBC_Encoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x01, 0x00);
DEFINE_GUID(CLSID_CCrypto_AES_CBC_Decoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00);
namespace NCrypto {
namespace NSevenZ {
const int kKeySize = 32;
class CKeyInfo
{
public:
int NumCyclesPower;
UInt32 SaltSize;
Byte Salt[16];
CByteBuffer Password;
Byte Key[kKeySize];
bool IsEqualTo(const CKeyInfo &a) const;
void CalculateDigest();
CKeyInfo() { Init(); }
void Init()
{
NumCyclesPower = 0;
SaltSize = 0;
for (int i = 0; i < sizeof(Salt); i++)
Salt[i] = 0;
}
};
class CKeyInfoCache
{
int Size;
CObjectVector<CKeyInfo> Keys;
public:
CKeyInfoCache(int size): Size(size) {}
bool Find(CKeyInfo &key);
// HRESULT Calculate(CKeyInfo &key);
void Add(CKeyInfo &key);
};
class CBase
{
CKeyInfoCache _cachedKeys;
protected:
CKeyInfo _key;
Byte _iv[16];
// int _ivSize;
void CalculateDigest();
CBase();
};
class CBaseCoder:
public ICompressFilter,
public ICryptoSetPassword,
public CMyUnknownImp,
public CBase
{
protected:
#ifndef CRYPTO_AES
CCoderLibrary _aesLibrary;
#endif
CMyComPtr<ICompressFilter> _aesFilter;
virtual HRESULT CreateFilter() = 0;
#ifndef CRYPTO_AES
HRESULT CreateFilterFromDLL(REFCLSID clsID);
#endif
public:
STDMETHOD(Init)();
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
};
class CEncoder:
public CBaseCoder,
public ICompressWriteCoderProperties
{
virtual HRESULT CreateFilter();
public:
MY_UNKNOWN_IMP2(
ICryptoSetPassword,
ICompressWriteCoderProperties)
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
};
class CDecoder:
public CBaseCoder,
public ICompressSetDecoderProperties2
{
virtual HRESULT CreateFilter();
public:
MY_UNKNOWN_IMP2(
ICryptoSetPassword,
ICompressSetDecoderProperties2)
STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
};
}}
#endif

View File

@@ -0,0 +1,111 @@
// DLLExports.cpp
#include "StdAfx.h"
#include "Common/MyInitGuid.h"
#include "Common/ComTry.h"
#include "7zAES.h"
/*
// {23170F69-40C1-278B-0703-000000000000}
DEFINE_GUID(CLSID_CCrypto_Hash_SHA256,
0x23170F69, 0x40C1, 0x278B, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
*/
// {23170F69-40C1-278B-06F1-070100000100}
DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
// {23170F69-40C1-278B-06F1-070100000000}
DEFINE_GUID(CLSID_CCrypto7zAESDecoder,
0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00);
HINSTANCE g_hInstance;
#ifndef _UNICODE
bool g_IsNT = false;
static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
#endif
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
}
return TRUE;
}
STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
{
COM_TRY_BEGIN
*outObject = 0;
int correctInterface = (*iid == IID_ICompressFilter);
CMyComPtr<ICompressFilter> filter;
if (*clsid == CLSID_CCrypto7zAESDecoder)
{
if (!correctInterface)
return E_NOINTERFACE;
filter = (ICompressFilter *)new NCrypto::NSevenZ::CDecoder();
}
else if (*clsid == CLSID_CCrypto7zAESEncoder)
{
if (!correctInterface)
return E_NOINTERFACE;
filter = (ICompressFilter *)new NCrypto::NSevenZ::CEncoder();
}
else
return CLASS_E_CLASSNOTAVAILABLE;
*outObject = filter.Detach();
COM_TRY_END
return S_OK;
}
STDAPI GetNumberOfMethods(UINT32 *numMethods)
{
*numMethods = 1;
return S_OK;
}
STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
{
if (index != 0)
return E_INVALIDARG;
::VariantClear((tagVARIANT *)value);
switch(propID)
{
case NMethodPropID::kID:
{
const char id[] = { 0x06, (char)(unsigned char)0xF1, 0x07, 0x01 };
if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
value->vt = VT_BSTR;
return S_OK;
}
case NMethodPropID::kName:
if ((value->bstrVal = ::SysAllocString(L"7zAES")) != 0)
value->vt = VT_BSTR;
return S_OK;
case NMethodPropID::kDecoder:
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)&CLSID_CCrypto7zAESDecoder, sizeof(GUID))) != 0)
value->vt = VT_BSTR;
return S_OK;
case NMethodPropID::kEncoder:
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)&CLSID_CCrypto7zAESEncoder, sizeof(GUID))) != 0)
value->vt = VT_BSTR;
return S_OK;
}
return S_OK;
}

View File

@@ -0,0 +1,3 @@
// StdAfx.cpp
#include "StdAfx.h"

8
CPP/7zip/Crypto/7zAES/StdAfx.h Executable file
View File

@@ -0,0 +1,8 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
#endif

52
CPP/7zip/Crypto/7zAES/makefile Executable file
View File

@@ -0,0 +1,52 @@
PROG = 7zAES.dll
DEF_FILE = ../Codec.def
CFLAGS = $(CFLAGS) -I ../../../
LIBS = $(LIBS) oleaut32.lib user32.lib
7ZAES_OBJS = \
$O\DllExports.obj \
7ZAES_OPT_OBJS = \
$O\7zAES.obj \
CRYPTO_HASH_OBJS = \
$O\Sha256.obj \
COMMON_OBJS = \
$O\Alloc.obj \
$O\NewHandler.obj \
$O\StringConvert.obj \
$O\Vector.obj \
WIN_OBJS = \
$O\DLL.obj \
$O\Synchronization.obj
7ZIP_COMMON_OBJS = \
$O\StreamObjects.obj \
$O\StreamUtils.obj \
OBJS = \
$O\StdAfx.obj \
$(7ZAES_OBJS) \
$(7ZAES_OPT_OBJS) \
$(CRYPTO_HASH_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
$O\resource.res
!include "../../../Build.mak"
$(7ZAES_OBJS): $(*B).cpp
$(COMPL)
$(7ZAES_OPT_OBJS): $(*B).cpp
$(COMPL)
$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)

View File

@@ -0,0 +1,3 @@
#include "../../MyVersionInfo.rc"
MY_VERSION_INFO_DLL("7zAES Codec", "7zAES")