4.45 beta

This commit is contained in:
Igor Pavlov
2007-04-17 00:00:00 +00:00
committed by Kornel Lesiński
parent d9666cf046
commit a145bfc7cf
458 changed files with 13144 additions and 18608 deletions

View File

@@ -6,21 +6,12 @@
#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;
#include "7zAES.h"
#ifndef CRYPTO_AES
extern HINSTANCE g_hInstance;
#endif
using namespace NWindows;
namespace NCrypto {
namespace NSevenZ {
@@ -219,36 +210,6 @@ STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 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();
@@ -268,38 +229,16 @@ 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
}
}}

View File

@@ -97,7 +97,11 @@ SOURCE=..\Codec.def
# End Source File
# Begin Source File
SOURCE=.\DllExports.cpp
SOURCE=..\..\Compress\CodecExports.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Compress\DllExports.cpp
# End Source File
# Begin Source File
@@ -118,14 +122,6 @@ SOURCE=.\StdAfx.h
# 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
@@ -174,14 +170,6 @@ SOURCE=..\..\..\Common\StringConvert.h
# 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
@@ -189,14 +177,6 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
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 ""
@@ -223,6 +203,107 @@ SOURCE=..\Hash\Sha256.cpp
SOURCE=..\Hash\Sha256.h
# End Source File
# End Group
# Begin Group "<22>"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=..\..\..\..\C\Alloc.h
# End Source File
# End Group
# Begin Group "AES"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\AES\aes.h
# End Source File
# Begin Source File
SOURCE=..\AES\AES_CBC.h
# End Source File
# Begin Source File
SOURCE=..\AES\aescpp.h
# End Source File
# Begin Source File
SOURCE=..\AES\aescrypt.c
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\AES\aeskey.c
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\AES\aesopt.h
# End Source File
# Begin Source File
SOURCE=..\AES\aestab.c
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\AES\MyAES.cpp
!IF "$(CFG)" == "7zAES - Win32 Release"
# ADD CPP /O2
# SUBTRACT CPP /YX /Yc /Yu
!ELSEIF "$(CFG)" == "7zAES - Win32 Debug"
# SUBTRACT CPP /YX /Yc /Yu
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\AES\MyAES.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\7zAES.cpp
@@ -241,5 +322,9 @@ SOURCE=.\7zAES.cpp
SOURCE=.\7zAES.h
# End Source File
# Begin Source File
SOURCE=.\7zAESRegister.cpp
# End Source File
# End Target
# End Project

View File

@@ -1,4 +1,4 @@
// 7z_AES.h
// 7zAES.h
#ifndef __CRYPTO_7Z_AES_H
#define __CRYPTO_7Z_AES_H
@@ -11,16 +11,6 @@
#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 {
@@ -77,9 +67,6 @@ class CBaseCoder:
public CBase
{
protected:
#ifndef CRYPTO_AES
CCoderLibrary _aesLibrary;
#endif
CMyComPtr<ICompressFilter> _aesFilter;
virtual HRESULT CreateFilter() = 0;

View File

@@ -0,0 +1,18 @@
// BranchRegister.cpp
#include "StdAfx.h"
#include "../../Common/RegisterCodec.h"
#include "7zAES.h"
static void *CreateCodec() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CDecoder()); }
#ifndef EXTRACT_ONLY
static void *CreateCodecOut() { return (void *)(ICompressFilter *)(new NCrypto::NSevenZ::CEncoder()); }
#else
#define CreateCodecOut 0
#endif
static CCodecInfo g_CodecInfo =
{ CreateCodec, CreateCodecOut, 0x06F10701, L"7zAES", 1, true };
REGISTER_CODEC(7zAES)

View File

@@ -3,45 +3,63 @@ DEF_FILE = ../Codec.def
CFLAGS = $(CFLAGS) -I ../../../
LIBS = $(LIBS) oleaut32.lib user32.lib
7ZAES_OBJS = \
COMPRESS_OBJS = \
$O\CodecExports.obj \
$O\DllExports.obj \
7ZAES_OPT_OBJS = \
$O\7zAES.obj \
$O\7zAESRegister.obj \
AES_OPT_OBJS = \
$O\MyAES.obj \
AES_ORIG_OBJS = \
$O\aescrypt.obj \
$O\aeskey.obj \
$O\aestab.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 \
C_OBJS = \
$O\Alloc.obj \
OBJS = \
$O\StdAfx.obj \
$(7ZAES_OBJS) \
$(COMPRESS_OBJS) \
$(7ZAES_OPT_OBJS) \
$(AES_OPT_OBJS) \
$(AES_ORIG_OBJS) \
$(CRYPTO_HASH_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(C_OBJS) \
$O\resource.res
!include "../../../Build.mak"
$(7ZAES_OBJS): $(*B).cpp
$(COMPRESS_OBJS): ../../Compress/$(*B).cpp
$(COMPL)
$(AES_OPT_OBJS): ../AES/$(*B).cpp
$(COMPL_O2)
$(AES_ORIG_OBJS): ../AES/$(*B).c
$(COMPL_O2_W3)
$(7ZAES_OPT_OBJS): $(*B).cpp
$(COMPL)
$(COMPL_O2)
$(CRYPTO_HASH_OBJS): ../../Crypto/Hash/$(*B).cpp
$(COMPL_O2)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
@@ -50,3 +68,5 @@ $(WIN_OBJS): ../../../Windows/$(*B).cpp
$(COMPL)
$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(C_OBJS): ../../../../C/$(*B).c
$(COMPL_O2)