diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2008-08-13 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:56 +0300 |
commit | 173c07e166fdf6fcd20f18ea73008f1b628945df (patch) | |
tree | 13ebea85cdc4c16ae93714ff0627ee9f91ad7e08 /CPP/7zip/Crypto | |
parent | 3901bf0ab88106a5b031cba7bc18d60cdebf7eef (diff) |
4.59 beta
Diffstat (limited to 'CPP/7zip/Crypto')
23 files changed, 68 insertions, 188 deletions
diff --git a/CPP/7zip/Crypto/7zAES/7zAES.cpp b/CPP/7zip/Crypto/7zAES/7zAES.cpp index ce6b7aef..f8034fd2 100755 --- a/CPP/7zip/Crypto/7zAES/7zAES.cpp +++ b/CPP/7zip/Crypto/7zAES/7zAES.cpp @@ -9,8 +9,8 @@ #include "../AES/MyAES.h" #include "7zAES.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Sha256.h" } @@ -139,7 +139,7 @@ STDMETHODIMP CEncoder::ResetInitVector() } STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) -{ +{ // _key.Init(); for (UInt32 i = _ivSize; i < sizeof(_iv); i++) _iv[i] = 0; @@ -149,7 +149,7 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) // _key.NumCyclesPower = 0x3F; _key.NumCyclesPower = 19; - Byte firstByte = (Byte)(_key.NumCyclesPower | + Byte firstByte = (Byte)(_key.NumCyclesPower | (((_key.SaltSize == 0) ? 0 : 1) << 7) | (((ivSize == 0) ? 0 : 1) << 6)); RINOK(outStream->Write(&firstByte, 1, NULL)); diff --git a/CPP/7zip/Crypto/7zAES/7zAES.h b/CPP/7zip/Crypto/7zAES/7zAES.h index ce14e2a1..ed2bb3cd 100755 --- a/CPP/7zip/Crypto/7zAES/7zAES.h +++ b/CPP/7zip/Crypto/7zAES/7zAES.h @@ -60,7 +60,7 @@ protected: CBase(); }; -class CBaseCoder: +class CBaseCoder: public ICompressFilter, public ICryptoSetPassword, public CMyUnknownImp, @@ -82,7 +82,7 @@ public: #ifndef EXTRACT_ONLY -class CEncoder: +class CEncoder: public CBaseCoder, public ICompressWriteCoderProperties, // public ICryptoResetSalt, @@ -101,7 +101,7 @@ public: }; #endif -class CDecoder: +class CDecoder: public CBaseCoder, public ICompressSetDecoderProperties2 { diff --git a/CPP/7zip/Crypto/7zAES/DllExports.cpp b/CPP/7zip/Crypto/7zAES/DllExports.cpp deleted file mode 100755 index 8766ded4..00000000 --- a/CPP/7zip/Crypto/7zAES/DllExports.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// 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; -} - diff --git a/CPP/7zip/Crypto/7zAES/StdAfx.cpp b/CPP/7zip/Crypto/7zAES/StdAfx.cpp deleted file mode 100755 index d0feea85..00000000 --- a/CPP/7zip/Crypto/7zAES/StdAfx.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// StdAfx.cpp - -#include "StdAfx.h" diff --git a/CPP/7zip/Crypto/AES/MyAES.cpp b/CPP/7zip/Crypto/AES/MyAES.cpp index 842a634e..286570a9 100755 --- a/CPP/7zip/Crypto/AES/MyAES.cpp +++ b/CPP/7zip/Crypto/AES/MyAES.cpp @@ -16,7 +16,7 @@ STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size) } STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size) -{ +{ if ((size & 0x7) != 0 || size < 16 || size > 32) return E_INVALIDARG; Aes_SetKeyEncode(&Aes.aes, data, size); @@ -39,7 +39,7 @@ STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size) } STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size) -{ +{ if ((size & 0x7) != 0 || size < 16 || size > 32) return E_INVALIDARG; Aes_SetKeyDecode(&Aes.aes, data, size); diff --git a/CPP/7zip/Crypto/AES/MyAES.h b/CPP/7zip/Crypto/AES/MyAES.h index ee1d2828..2e99f158 100755 --- a/CPP/7zip/Crypto/AES/MyAES.h +++ b/CPP/7zip/Crypto/AES/MyAES.h @@ -8,8 +8,8 @@ #include "../../ICoder.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Aes.h" } @@ -19,7 +19,7 @@ class CAesCbcEncoder: public ICompressFilter, public ICryptoProperties, public CMyUnknownImp -{ +{ CAesCbc Aes; public: MY_UNKNOWN_IMP1(ICryptoProperties) @@ -33,7 +33,7 @@ class CAesCbcDecoder: public ICompressFilter, public ICryptoProperties, public CMyUnknownImp -{ +{ CAesCbc Aes; public: MY_UNKNOWN_IMP1(ICryptoProperties) diff --git a/CPP/7zip/Crypto/AES/StdAfx.cpp b/CPP/7zip/Crypto/AES/StdAfx.cpp deleted file mode 100755 index d0feea85..00000000 --- a/CPP/7zip/Crypto/AES/StdAfx.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// StdAfx.cpp - -#include "StdAfx.h" diff --git a/CPP/7zip/Crypto/Hash/HmacSha1.cpp b/CPP/7zip/Crypto/Hash/HmacSha1.cpp index a5c20a75..a66d6271 100755 --- a/CPP/7zip/Crypto/Hash/HmacSha1.cpp +++ b/CPP/7zip/Crypto/Hash/HmacSha1.cpp @@ -20,7 +20,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize) _sha.Final(keyTemp); keySize = kDigestSize; } - else + else for (i = 0; i < keySize; i++) keyTemp[i] = key[i]; for (i = 0; i < kBlockSize; i++) @@ -34,7 +34,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize) } void CHmac::Final(Byte *mac, size_t macSize) -{ +{ Byte digest[kDigestSize]; _sha.Final(digest); _sha2.Update(digest, kDigestSize); @@ -59,14 +59,14 @@ void CHmac32::SetKey(const Byte *key, size_t keySize) sha.Final(digest); for (int i = 0 ; i < kDigestSizeInWords; i++) - keyTemp[i] = + keyTemp[i] = ((UInt32)(digest[i * 4 + 0]) << 24) | ((UInt32)(digest[i * 4 + 1]) << 16) | ((UInt32)(digest[i * 4 + 2]) << 8) | ((UInt32)(digest[i * 4 + 3])); keySize = kDigestSizeInWords; } - else + else for (size_t i = 0; i < keySize; i++) keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3))); for (i = 0; i < kBlockSizeInWords; i++) @@ -80,7 +80,7 @@ void CHmac32::SetKey(const Byte *key, size_t keySize) } void CHmac32::Final(UInt32 *mac, size_t macSize) -{ +{ UInt32 digest[kDigestSizeInWords]; _sha.Final(digest); _sha2.Update(digest, kDigestSizeInWords); diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp index b11881b7..cbbdec89 100755 --- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp +++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp @@ -7,7 +7,7 @@ namespace NCrypto { namespace NSha1 { -void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize, +void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize, UInt32 numIterations, Byte *key, size_t keySize) { CHmac baseCtx; @@ -39,7 +39,7 @@ void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSi } } -void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize, +void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize, UInt32 numIterations, UInt32 *key, size_t keySize) { CHmac32 baseCtx; diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h index 00a5e009..68e85ee3 100755 --- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h +++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h @@ -10,10 +10,10 @@ namespace NCrypto { namespace NSha1 { -void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize, +void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize, UInt32 numIterations, Byte *key, size_t keySize); -void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize, +void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize, UInt32 numIterations, UInt32 *key, size_t keySize); }} diff --git a/CPP/7zip/Crypto/Hash/RandGen.cpp b/CPP/7zip/Crypto/Hash/RandGen.cpp index 9ae36155..a030a0d2 100755 --- a/CPP/7zip/Crypto/Hash/RandGen.cpp +++ b/CPP/7zip/Crypto/Hash/RandGen.cpp @@ -28,7 +28,7 @@ // Maybe it's possible to restore original timer value from generated value. void CRandomGenerator::Init() -{ +{ NCrypto::NSha1::CContext hash; hash.Init(); @@ -82,7 +82,7 @@ void CRandomGenerator::Init() static NWindows::NSynchronization::CCriticalSection g_CriticalSection; void CRandomGenerator::Generate(Byte *data, unsigned int size) -{ +{ g_CriticalSection.Enter(); if (_needInit) Init(); diff --git a/CPP/7zip/Crypto/Hash/RandGen.h b/CPP/7zip/Crypto/Hash/RandGen.h index 3b58a032..3f06b26b 100755 --- a/CPP/7zip/Crypto/Hash/RandGen.h +++ b/CPP/7zip/Crypto/Hash/RandGen.h @@ -13,7 +13,7 @@ class CRandomGenerator void Init(); public: CRandomGenerator(): _needInit(true) {}; - void Generate(Byte *data, unsigned int size); + void Generate(Byte *data, unsigned size); }; extern CRandomGenerator g_RandomGenerator; diff --git a/CPP/7zip/Crypto/Hash/Sha1.cpp b/CPP/7zip/Crypto/Hash/Sha1.cpp index 8d56b3dc..2962c654 100755 --- a/CPP/7zip/Crypto/Hash/Sha1.cpp +++ b/CPP/7zip/Crypto/Hash/Sha1.cpp @@ -1,12 +1,12 @@ // Sha1.cpp -// This file is based on public domain +// This file is based on public domain // Steve Reid and Wei Dai's code from Crypto++ #include "StdAfx.h" #include "Sha1.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/RotateDefs.h" } @@ -16,7 +16,7 @@ namespace NSha1 { // define it for speed optimization // #define _SHA1_UNROLL -static const unsigned int kNumW = +static const unsigned int kNumW = #ifdef _SHA1_UNROLL 16; #else @@ -79,9 +79,9 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR #ifdef _SHA1_UNROLL - RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35); - RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55); - RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75); + RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35); + RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55); + RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75); #else i = 20; for (; i < 40; i += 5) { RX_5(R2, i); } @@ -101,7 +101,7 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR // Wipe variables // a = b = c = d = e = 0; -} +} void CContextBase::PrepareBlock(UInt32 *block, unsigned int size) const { @@ -165,7 +165,7 @@ void CContext::Final(Byte *digest) UpdateBlock(); int i; - for (i = 0; i < kDigestSizeInWords; i++) + for (i = 0; i < kDigestSizeInWords; i++) { UInt32 state = _state[i] & 0xFFFFFFFF; *digest++ = (Byte)(state >> 24); diff --git a/CPP/7zip/Crypto/Hash/Sha1.h b/CPP/7zip/Crypto/Hash/Sha1.h index ebb11142..8ad8675b 100755 --- a/CPP/7zip/Crypto/Hash/Sha1.h +++ b/CPP/7zip/Crypto/Hash/Sha1.h @@ -1,5 +1,5 @@ // Sha1.h -// This file is based on public domain +// This file is based on public domain // Steve Reid and Wei Dai's code from Crypto++ #ifndef __SHA1_H @@ -26,9 +26,9 @@ class CContextBase protected: UInt32 _state[5]; UInt64 _count; - void UpdateBlock(UInt32 *data, bool returnRes = false) - { - GetBlockDigest(data, _state, returnRes); + void UpdateBlock(UInt32 *data, bool returnRes = false) + { + GetBlockDigest(data, _state, returnRes); _count++; } public: diff --git a/CPP/7zip/Crypto/Rar20/Rar20Cipher.h b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h index e2091cda..465cc42a 100755 --- a/CPP/7zip/Crypto/Rar20/Rar20Cipher.h +++ b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h @@ -13,7 +13,7 @@ namespace NCrypto { namespace NRar20 { -class CDecoder: +class CDecoder: public ICompressFilter, public ICryptoSetPassword, public CMyUnknownImp diff --git a/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp index 6cd2d450..d688644d 100755 --- a/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp +++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp @@ -3,9 +3,9 @@ #include "StdAfx.h" #include "Rar20Crypto.h" -extern "C" -{ - #include "../../../../C/7zCrc.h" +extern "C" +{ + #include "../../../../C/7zCrc.h" } #define rol(x,n) (((x) << (n)) | ((x) >> (8 * sizeof(x) - (n)))) diff --git a/CPP/7zip/Crypto/Rar20/Rar20Crypto.h b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h index 071d01f1..572db3dd 100755 --- a/CPP/7zip/Crypto/Rar20/Rar20Crypto.h +++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h @@ -14,9 +14,9 @@ class CData UInt32 Keys[4]; UInt32 SubstLong(UInt32 t) { - return (UInt32)SubstTable[(int)t & 255] | + return (UInt32)SubstTable[(int)t & 255] | ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) | - ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) | + ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) | ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24); } diff --git a/CPP/7zip/Crypto/RarAES/RarAES.h b/CPP/7zip/Crypto/RarAES/RarAES.h index a99ad531..d43b3889 100755 --- a/CPP/7zip/Crypto/RarAES/RarAES.h +++ b/CPP/7zip/Crypto/RarAES/RarAES.h @@ -10,8 +10,8 @@ #include "../../ICoder.h" #include "../../IPassword.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Aes.h" } @@ -20,7 +20,7 @@ namespace NRar29 { const UInt32 kRarAesKeySize = 16; -class CDecoder: +class CDecoder: public ICompressFilter, public ICompressSetDecoderProperties2, public ICryptoSetPassword, diff --git a/CPP/7zip/Crypto/WzAES/StdAfx.cpp b/CPP/7zip/Crypto/WzAES/StdAfx.cpp deleted file mode 100755 index d0feea85..00000000 --- a/CPP/7zip/Crypto/WzAES/StdAfx.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// StdAfx.cpp - -#include "StdAfx.h" diff --git a/CPP/7zip/Crypto/WzAES/WzAES.cpp b/CPP/7zip/Crypto/WzAES/WzAES.cpp index 704ea9fc..ba213626 100755 --- a/CPP/7zip/Crypto/WzAES/WzAES.cpp +++ b/CPP/7zip/Crypto/WzAES/WzAES.cpp @@ -1,6 +1,6 @@ // WzAES.cpp /* -This code implements Brian Gladman's scheme +This code implements Brian Gladman's scheme specified in password Based File Encryption Utility. Note: you must include Crypto/AES/MyAES.cpp to project to initialize AES tables @@ -39,12 +39,12 @@ STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size) (p)[2] = (Byte)(x >> 16); (p)[3] = (Byte)(x >> 24); } void CBaseCoder::EncryptData(Byte *data, UInt32 size) -{ +{ unsigned int pos = _blockPos; for (; size > 0; size--) { if (pos == AES_BLOCK_SIZE) - { + { if (++_counter[0] == 0) _counter[1]++; UInt32 temp[4]; @@ -65,7 +65,7 @@ void CBaseCoder::EncryptData(Byte *data, UInt32 size) static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize) { for (int i = 0 ; i < destSize; i++) - dest[i] = + dest[i] = ((UInt32)(src[i * 4 + 0]) << 24) | ((UInt32)(src[i * 4 + 1]) << 16) | ((UInt32)(src[i * 4 + 2]) << 8) | @@ -85,9 +85,9 @@ STDMETHODIMP CBaseCoder::Init() #ifdef _NO_WZAES_OPTIMIZATIONS NSha1::Pbkdf2Hmac( - _key.Password, _key.Password.GetCapacity(), + _key.Password, _key.Password.GetCapacity(), _key.Salt, _key.GetSaltSize(), - kNumKeyGenIterations, + kNumKeyGenIterations, buf, keysTotalSize); #else @@ -98,11 +98,11 @@ STDMETHODIMP CBaseCoder::Init() UInt32 saltSizeInWords = _key.GetSaltSize() / 4; BytesToBeUInt32s(_key.Salt, salt, saltSizeInWords); NSha1::Pbkdf2Hmac32( - _key.Password, _key.Password.GetCapacity(), + _key.Password, _key.Password.GetCapacity(), salt, saltSizeInWords, - kNumKeyGenIterations, + kNumKeyGenIterations, buf32, key32SizeTotal); - for (UInt32 j = 0; j < keysTotalSize; j++) + for (UInt32 j = 0; j < keysTotalSize; j++) buf[j] = (Byte)(buf32[j / 4] >> (24 - 8 * (j & 3))); #endif @@ -121,7 +121,7 @@ STDMETHODIMP CBaseCoder::Init() /* STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream) -{ +{ Byte keySizeMode = 3; return outStream->Write(&keySizeMode, 1, NULL); } diff --git a/CPP/7zip/Crypto/WzAES/WzAES.h b/CPP/7zip/Crypto/WzAES/WzAES.h index fa14410a..ad35035c 100755 --- a/CPP/7zip/Crypto/WzAES/WzAES.h +++ b/CPP/7zip/Crypto/WzAES/WzAES.h @@ -1,10 +1,10 @@ // WzAES.h /* -This code implements Brian Gladman's scheme +This code implements Brian Gladman's scheme specified in password Based File Encryption Utility: - AES encryption (128,192,256-bit) in Counter (CTR) mode. - HMAC-SHA1 authentication for encrypted data (10 bytes) - - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and + - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and Salt (saltSize = aesKeySize / 2). - 2 bytes contain Password Verifier's Code */ @@ -21,8 +21,8 @@ specified in password Based File Encryption Utility: #include "../../ICoder.h" #include "../../IPassword.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/Aes.h" } @@ -53,7 +53,7 @@ public: void Init() { KeySizeMode = 3; } }; -class CBaseCoder: +class CBaseCoder: public ICompressFilter, public ICryptoSetPassword, public CMyUnknownImp @@ -79,7 +79,7 @@ public: UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; } }; -class CEncoder: +class CEncoder: public CBaseCoder // public ICompressWriteCoderProperties { @@ -99,7 +99,7 @@ public: } }; -class CDecoder: +class CDecoder: public CBaseCoder, public ICompressSetDecoderProperties2 { diff --git a/CPP/7zip/Crypto/Zip/ZipCipher.h b/CPP/7zip/Crypto/Zip/ZipCipher.h index d750336c..83732a41 100755 --- a/CPP/7zip/Crypto/Zip/ZipCipher.h +++ b/CPP/7zip/Crypto/Zip/ZipCipher.h @@ -14,7 +14,7 @@ namespace NCrypto { namespace NZip { -class CEncoder : +class CEncoder : public ICompressFilter, public ICryptoSetPassword, public ICryptoSetCRC, @@ -36,7 +36,7 @@ public: }; -class CDecoder: +class CDecoder: public ICompressFilter, public ICryptoSetPassword, public CMyUnknownImp diff --git a/CPP/7zip/Crypto/Zip/ZipCrypto.cpp b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp index 7389ba25..55ec8e54 100755 --- a/CPP/7zip/Crypto/Zip/ZipCrypto.cpp +++ b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp @@ -3,8 +3,8 @@ #include "StdAfx.h" #include "ZipCipher.h" -extern "C" -{ +extern "C" +{ #include "../../../../C/7zCrc.h" } |