summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto
diff options
context:
space:
mode:
Diffstat (limited to 'installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto')
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp244
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h117
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp18
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp109
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h39
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp57
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h45
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp83
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp107
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h21
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp133
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h50
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp139
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h59
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp211
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h68
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp209
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h116
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp128
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h71
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp177
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h53
23 files changed, 0 insertions, 2275 deletions
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp
deleted file mode 100644
index 88149eb10..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-// 7zAes.cpp
-
-#include "StdAfx.h"
-
-#include "../../../C/Sha256.h"
-
-#include "Windows/Synchronization.h"
-
-#include "../Common/StreamObjects.h"
-#include "../Common/StreamUtils.h"
-
-#include "7zAes.h"
-#include "MyAes.h"
-
-#ifndef EXTRACT_ONLY
-#include "RandGen.h"
-#endif
-
-using namespace NWindows;
-
-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 < static_cast< UInt32 >( kKeySize ); i++)
- Key[pos++] = Password[i];
- for (; pos < static_cast< UInt32 >( kKeySize ); pos++)
- Key[pos] = 0;
- }
- else
- {
- CSha256 sha;
- Sha256_Init(&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++)
- {
- Sha256_Update(&sha, Salt, (size_t)SaltSize);
- Sha256_Update(&sha, Password, Password.GetCapacity());
- Sha256_Update(&sha, temp, 8);
- for (int i = 0; i < 8; i++)
- if (++(temp[i]) != 0)
- break;
- }
- Sha256_Final(&sha, 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),
- _ivSize(0)
-{
- for (size_t 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);
- }
-}
-
-#ifndef EXTRACT_ONLY
-
-/*
-STDMETHODIMP CEncoder::ResetSalt()
-{
- _key.SaltSize = 4;
- g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
- return S_OK;
-}
-*/
-
-STDMETHODIMP CEncoder::ResetInitVector()
-{
- _ivSize = 8;
- g_RandomGenerator.Generate(_iv, (unsigned)_ivSize);
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
- // _key.Init();
- for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
- _iv[i] = 0;
-
- UInt32 ivSize = _ivSize;
-
- // _key.NumCyclesPower = 0x3F;
- _key.NumCyclesPower = 19;
-
- 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));
- }
- if (ivSize > 0)
- {
- RINOK(WriteStream(outStream, _iv, ivSize));
- }
- return S_OK;
-}
-
-HRESULT CEncoder::CreateFilter()
-{
- _aesFilter = new CAesCbcEncoder;
- return S_OK;
-}
-
-#endif
-
-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_t)size);
- memcpy(_key.Password, data, (size_t)size);
- return S_OK;
-}
-
-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);
-}
-
-HRESULT CDecoder::CreateFilter()
-{
- _aesFilter = new CAesCbcDecoder;
- return S_OK;
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h
deleted file mode 100644
index ea9c585e8..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAes.h
+++ /dev/null
@@ -1,117 +0,0 @@
-// 7zAes.h
-
-#ifndef __CRYPTO_7Z_AES_H
-#define __CRYPTO_7Z_AES_H
-
-#include "Common/Buffer.h"
-#include "Common/MyCom.h"
-#include "Common/MyVector.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-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 (unsigned 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];
- UInt32 _ivSize;
- void CalculateDigest();
- CBase();
-};
-
-class CBaseCoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp,
- public CBase
-{
-protected:
- 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);
-};
-
-#ifndef EXTRACT_ONLY
-
-class CEncoder:
- public CBaseCoder,
- public ICompressWriteCoderProperties,
- // public ICryptoResetSalt,
- public ICryptoResetInitVector
-{
- virtual HRESULT CreateFilter();
-public:
- MY_UNKNOWN_IMP3(
- ICryptoSetPassword,
- ICompressWriteCoderProperties,
- // ICryptoResetSalt,
- ICryptoResetInitVector)
- STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
- // STDMETHOD(ResetSalt)();
- STDMETHOD(ResetInitVector)();
-};
-#endif
-
-class CDecoder:
- public CBaseCoder,
- public ICompressSetDecoderProperties2
-{
- virtual HRESULT CreateFilter();
-public:
- MY_UNKNOWN_IMP2(
- ICryptoSetPassword,
- ICompressSetDecoderProperties2)
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp
deleted file mode 100644
index 5e57748f5..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/7zAesRegister.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// 7zAesRegister.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)
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp
deleted file mode 100644
index 13a7ff81d..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-// HmacSha1.cpp
-
-#include "StdAfx.h"
-
-#include "HmacSha1.h"
-
-namespace NCrypto {
-namespace NSha1 {
-
-void CHmac::SetKey(const Byte *key, size_t keySize)
-{
- Byte keyTemp[kBlockSize];
- size_t i;
- for (i = 0; i < kBlockSize; i++)
- keyTemp[i] = 0;
- if(keySize > kBlockSize)
- {
- _sha.Init();
- _sha.Update(key, keySize);
- _sha.Final(keyTemp);
- keySize = kDigestSize;
- }
- else
- for (i = 0; i < keySize; i++)
- keyTemp[i] = key[i];
- for (i = 0; i < kBlockSize; i++)
- keyTemp[i] ^= 0x36;
- _sha.Init();
- _sha.Update(keyTemp, kBlockSize);
- for (i = 0; i < kBlockSize; i++)
- keyTemp[i] ^= 0x36 ^ 0x5C;
- _sha2.Init();
- _sha2.Update(keyTemp, kBlockSize);
-}
-
-void CHmac::Final(Byte *mac, size_t macSize)
-{
- Byte digest[kDigestSize];
- _sha.Final(digest);
- _sha2.Update(digest, kDigestSize);
- _sha2.Final(digest);
- for(size_t i = 0; i < macSize; i++)
- mac[i] = digest[i];
-}
-
-
-void CHmac32::SetKey(const Byte *key, size_t keySize)
-{
- UInt32 keyTemp[kBlockSizeInWords];
- size_t i;
- for (i = 0; i < kBlockSizeInWords; i++)
- keyTemp[i] = 0;
- if(keySize > kBlockSize)
- {
- CContext sha;
- sha.Init();
- sha.Update(key, keySize);
- Byte digest[kDigestSize];
- sha.Final(digest);
-
- for (unsigned int i = 0 ; i < kDigestSizeInWords; 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
- for (size_t i = 0; i < keySize; i++)
- keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
- for (i = 0; i < kBlockSizeInWords; i++)
- keyTemp[i] ^= 0x36363636;
- _sha.Init();
- _sha.Update(keyTemp, kBlockSizeInWords);
- for (i = 0; i < kBlockSizeInWords; i++)
- keyTemp[i] ^= 0x36363636 ^ 0x5C5C5C5C;
- _sha2.Init();
- _sha2.Update(keyTemp, kBlockSizeInWords);
-}
-
-void CHmac32::Final(UInt32 *mac, size_t macSize)
-{
- UInt32 digest[kDigestSizeInWords];
- _sha.Final(digest);
- _sha2.Update(digest, kDigestSizeInWords);
- _sha2.Final(digest);
- for(size_t i = 0; i < macSize; i++)
- mac[i] = digest[i];
-}
-
-void CHmac32::GetLoopXorDigest(UInt32 *mac, UInt32 numIteration)
-{
- UInt32 block[kBlockSizeInWords];
- UInt32 block2[kBlockSizeInWords];
- _sha.PrepareBlock(block, kDigestSizeInWords);
- _sha2.PrepareBlock(block2, kDigestSizeInWords);
- for(unsigned int s = 0; s < kDigestSizeInWords; s++)
- block[s] = mac[s];
- for(UInt32 i = 0; i < numIteration; i++)
- {
- _sha.GetBlockDigest(block, block2);
- _sha2.GetBlockDigest(block2, block);
- for (unsigned int s = 0; s < kDigestSizeInWords; s++)
- mac[s] ^= block[s];
- }
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h
deleted file mode 100644
index d7181329c..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/HmacSha1.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// HmacSha1.h
-// Implements HMAC-SHA-1 (RFC2104, FIPS-198)
-
-#ifndef __CRYPTO_HMAC_SHA1_H
-#define __CRYPTO_HMAC_SHA1_H
-
-#include "Sha1.h"
-
-namespace NCrypto {
-namespace NSha1 {
-
-// Use: SetKey(key, keySize); for () Update(data, size); Final(mac, macSize);
-
-class CHmac
-{
- CContext _sha;
- CContext _sha2;
-public:
- void SetKey(const Byte *key, size_t keySize);
- void Update(const Byte *data, size_t dataSize) { _sha.Update(data, dataSize); }
- void Final(Byte *mac, size_t macSize = kDigestSize);
-};
-
-class CHmac32
-{
- CContext32 _sha;
- CContext32 _sha2;
-public:
- void SetKey(const Byte *key, size_t keySize);
- void Update(const UInt32 *data, size_t dataSize) { _sha.Update(data, dataSize); }
- void Final(UInt32 *mac, size_t macSize = kDigestSizeInWords);
-
- // It'sa for hmac function. in,out: mac[kDigestSizeInWords].
- void GetLoopXorDigest(UInt32 *mac, UInt32 numIteration);
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp
deleted file mode 100644
index 5b0d1e8a4..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Crypto/MyAes.cpp
-
-#include "StdAfx.h"
-
-#include "MyAes.h"
-
-namespace NCrypto {
-
-struct CAesTabInit { CAesTabInit() { AesGenTables();} } g_AesTabInit;
-
-STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; }
-
-STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
-{
- return (UInt32)AesCbc_Encode(&Aes, data, 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);
- return S_OK;
-}
-
-STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size)
-{
- if (size != AES_BLOCK_SIZE)
- return E_INVALIDARG;
- AesCbc_Init(&Aes, data);
- return S_OK;
-}
-
-STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; }
-
-STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
-{
- return (UInt32)AesCbc_Decode(&Aes, data, 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);
- return S_OK;
-}
-
-STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size)
-{
- if (size != AES_BLOCK_SIZE)
- return E_INVALIDARG;
- AesCbc_Init(&Aes, data);
- return S_OK;
-}
-
-}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h
deleted file mode 100644
index 24e90d6f1..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/MyAes.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Crypto/MyAes.h
-
-#ifndef __CRYPTO_MY_AES_H
-#define __CRYPTO_MY_AES_H
-
-#include "../../../C/Aes.h"
-
-#include "../../Common/MyCom.h"
-#include "../../Common/Types.h"
-
-#include "../ICoder.h"
-
-namespace NCrypto {
-
-class CAesCbcEncoder:
- public ICompressFilter,
- public ICryptoProperties,
- public CMyUnknownImp
-{
- CAesCbc Aes;
-public:
- MY_UNKNOWN_IMP1(ICryptoProperties)
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(SetKey)(const Byte *data, UInt32 size);
- STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
-};
-
-class CAesCbcDecoder:
- public ICompressFilter,
- public ICryptoProperties,
- public CMyUnknownImp
-{
- CAesCbc Aes;
-public:
- MY_UNKNOWN_IMP1(ICryptoProperties)
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(SetKey)(const Byte *data, UInt32 size);
- STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
-};
-
-}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp
deleted file mode 100644
index cbbdec89d..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Pbkdf2HmacSha1.cpp
-
-#include "StdAfx.h"
-
-#include "HmacSha1.h"
-
-namespace NCrypto {
-namespace NSha1 {
-
-void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
- UInt32 numIterations, Byte *key, size_t keySize)
-{
- CHmac baseCtx;
- baseCtx.SetKey(pwd, pwdSize);
- for (UInt32 i = 1; keySize > 0; i++)
- {
- CHmac ctx = baseCtx;
- ctx.Update(salt, saltSize);
- Byte u[kDigestSize] = { (Byte)(i >> 24), (Byte)(i >> 16), (Byte)(i >> 8), (Byte)(i) };
- const unsigned int curSize = (keySize < kDigestSize) ? (unsigned int)keySize : kDigestSize;
- ctx.Update(u, 4);
- ctx.Final(u, kDigestSize);
-
- unsigned int s;
- for (s = 0; s < curSize; s++)
- key[s] = u[s];
-
- for (UInt32 j = numIterations; j > 1; j--)
- {
- ctx = baseCtx;
- ctx.Update(u, kDigestSize);
- ctx.Final(u, kDigestSize);
- for (s = 0; s < curSize; s++)
- key[s] ^= u[s];
- }
-
- key += curSize;
- keySize -= curSize;
- }
-}
-
-void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
- UInt32 numIterations, UInt32 *key, size_t keySize)
-{
- CHmac32 baseCtx;
- baseCtx.SetKey(pwd, pwdSize);
- for (UInt32 i = 1; keySize > 0; i++)
- {
- CHmac32 ctx = baseCtx;
- ctx.Update(salt, saltSize);
- UInt32 u[kDigestSizeInWords] = { i };
- const unsigned int curSize = (keySize < kDigestSizeInWords) ? (unsigned int)keySize : kDigestSizeInWords;
- ctx.Update(u, 1);
- ctx.Final(u, kDigestSizeInWords);
-
- // Speed-optimized code start
- ctx = baseCtx;
- ctx.GetLoopXorDigest(u, numIterations - 1);
- // Speed-optimized code end
-
- unsigned int s;
- for (s = 0; s < curSize; s++)
- key[s] = u[s];
-
- /*
- // Default code start
- for (UInt32 j = numIterations; j > 1; j--)
- {
- ctx = baseCtx;
- ctx.Update(u, kDigestSizeInWords);
- ctx.Final(u, kDigestSizeInWords);
- for (s = 0; s < curSize; s++)
- key[s] ^= u[s];
- }
- // Default code end
- */
-
- key += curSize;
- keySize -= curSize;
- }
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h
deleted file mode 100644
index bb90e1214..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Pbkdf2HmacSha1.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Pbkdf2HmacSha1.h
-// Password-Based Key Derivation Function (RFC 2898, PKCS #5) based on HMAC-SHA-1
-
-#ifndef __CRYPTO_PBKDF2_HMAC_SHA1_H
-#define __CRYPTO_PBKDF2_HMAC_SHA1_H
-
-#include <stddef.h>
-#include "../../Common/Types.h"
-
-namespace NCrypto {
-namespace NSha1 {
-
-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,
- UInt32 numIterations, UInt32 *key, size_t keySize);
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp
deleted file mode 100644
index e0e2e3abd..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// RandGen.cpp
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include "Windows/Synchronization.h"
-#include "RandGen.h"
-
-#ifndef _WIN32
-#include <unistd.h>
-#define USE_POSIX_TIME
-#define USE_POSIX_TIME2
-#endif
-
-#ifdef USE_POSIX_TIME
-#include <time.h>
-#ifdef USE_POSIX_TIME2
-#include <sys/time.h>
-#endif
-#endif
-
-// This is not very good random number generator.
-// Please use it only for salt.
-// First generated data block depends from timer and processID.
-// Other generated data blocks depend from previous state
-// Maybe it's possible to restore original timer value from generated value.
-
-void CRandomGenerator::Init()
-{
- NCrypto::NSha1::CContext hash;
- hash.Init();
-
- #ifdef _WIN32
- DWORD w = ::GetCurrentProcessId();
- hash.Update((const Byte *)&w, sizeof(w));
- w = ::GetCurrentThreadId();
- hash.Update((const Byte *)&w, sizeof(w));
- #else
- pid_t pid = getpid();
- hash.Update((const Byte *)&pid, sizeof(pid));
- pid = getppid();
- hash.Update((const Byte *)&pid, sizeof(pid));
- #endif
-
- for (int i = 0; i < 1000; i++)
- {
- #ifdef _WIN32
- LARGE_INTEGER v;
- if (::QueryPerformanceCounter(&v))
- hash.Update((const Byte *)&v.QuadPart, sizeof(v.QuadPart));
- #endif
-
- #ifdef USE_POSIX_TIME
- #ifdef USE_POSIX_TIME2
- timeval v;
- if (gettimeofday(&v, 0) == 0)
- {
- hash.Update((const Byte *)&v.tv_sec, sizeof(v.tv_sec));
- hash.Update((const Byte *)&v.tv_usec, sizeof(v.tv_usec));
- }
- #endif
- time_t v2 = time(NULL);
- hash.Update((const Byte *)&v2, sizeof(v2));
- #endif
-
- DWORD tickCount = ::GetTickCount();
- hash.Update((const Byte *)&tickCount, sizeof(tickCount));
-
- for (int j = 0; j < 100; j++)
- {
- hash.Final(_buff);
- hash.Init();
- hash.Update(_buff, NCrypto::NSha1::kDigestSize);
- }
- }
- hash.Final(_buff);
- _needInit = false;
-}
-
-static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
-
-void CRandomGenerator::Generate(Byte *data, unsigned int size)
-{
- g_CriticalSection.Enter();
- if (_needInit)
- Init();
- while (size > 0)
- {
- NCrypto::NSha1::CContext hash;
-
- hash.Init();
- hash.Update(_buff, NCrypto::NSha1::kDigestSize);
- hash.Final(_buff);
-
- hash.Init();
- UInt32 salt = 0xF672ABD1;
- hash.Update((const Byte *)&salt, sizeof(salt));
- hash.Update(_buff, NCrypto::NSha1::kDigestSize);
- Byte buff[NCrypto::NSha1::kDigestSize];
- hash.Final(buff);
- for (unsigned int i = 0; i < NCrypto::NSha1::kDigestSize && size > 0; i++, size--)
- *data++ = buff[i];
- }
- g_CriticalSection.Leave();
-}
-
-CRandomGenerator g_RandomGenerator;
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h
deleted file mode 100644
index 209445c43..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RandGen.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// RandGen.h
-
-#ifndef __CRYPTO_RAND_GEN_H
-#define __CRYPTO_RAND_GEN_H
-
-#include "Sha1.h"
-
-class CRandomGenerator
-{
- Byte _buff[NCrypto::NSha1::kDigestSize];
- bool _needInit;
-
- void Init();
-public:
- CRandomGenerator(): _needInit(true) {};
- void Generate(Byte *data, unsigned size);
-};
-
-extern CRandomGenerator g_RandomGenerator;
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp
deleted file mode 100644
index c2df0e527..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-// Crypto/Rar20Crypto.cpp
-
-#include "StdAfx.h"
-
-#include "../../../C/7zCrc.h"
-#include "../../../C/CpuArch.h"
-#include "../../../C/RotateDefs.h"
-
-#include "Rar20Crypto.h"
-
-namespace NCrypto {
-namespace NRar20 {
-
-static const int kNumRounds = 32;
-
-static const Byte InitSubstTable[256] = {
- 215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221, 2, 42,
- 232, 1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137,
- 255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86, 6,
- 71, 24,171,196,101,113,218,123, 93, 91,163,178,202, 67, 44,235,
- 107,250, 75,234, 49,167,125,211, 83,114,157,144, 32,193,143, 36,
- 158,124,247,187, 89,214,141, 47,121,228, 61,130,213,194,174,251,
- 97,110, 54,229,115, 57,152, 94,105,243,212, 55,209,245, 63, 11,
- 164,200, 31,156, 81,176,227, 21, 76, 99,139,188,127, 17,248, 51,
- 207,120,189,210, 8,226, 41, 72,183,203,135,165,166, 60, 98, 7,
- 122, 38,155,170, 69,172,252,238, 39,134, 59,128,236, 27,240, 80,
- 131, 3, 85,206,145, 79,154,142,159,220,201,133, 74, 64, 20,129,
- 224,185,138,103,173,182, 43, 34,254, 82,198,151,231,180, 58, 10,
- 118, 26,102, 12, 50,132, 22,191,136,111,162,179, 45, 4,148,108,
- 161, 56, 78,126,242,222, 15,175,146, 23, 33,241,181,190, 77,225,
- 0, 46,169,186, 68, 95,237, 65, 53,208,253,168, 9, 18,100, 52,
- 116,184,160, 96,109, 37, 30,106,140,104,150, 5,204,117,112, 84
-};
-
-void CData::UpdateKeys(const Byte *data)
-{
- for (int i = 0; i < 16; i += 4)
- for (int j = 0; j < 4; j++)
- Keys[j] ^= g_CrcTable[data[i + j]];
-}
-
-static void Swap(Byte *b1, Byte *b2)
-{
- Byte b = *b1;
- *b1 = *b2;
- *b2 = b;
-}
-
-void CData::SetPassword(const Byte *password, UInt32 passwordLen)
-{
- Keys[0] = 0xD3A3B879L;
- Keys[1] = 0x3F6D12F7L;
- Keys[2] = 0x7515A235L;
- Keys[3] = 0xA4E7F123L;
-
- Byte psw[256];
- memset(psw, 0, sizeof(psw));
- memcpy(psw, password, passwordLen);
- memcpy(SubstTable, InitSubstTable, sizeof(SubstTable));
-
- for (UInt32 j = 0; j < 256; j++)
- for (UInt32 i = 0; i < passwordLen; i += 2)
- {
- UInt32 n2 = (Byte)g_CrcTable[(psw[i + 1] + j) & 0xFF];
- UInt32 n1 = (Byte)g_CrcTable[(psw[i] - j) & 0xFF];
- for (UInt32 k = 1; (n1 & 0xFF) != n2; n1++, k++)
- Swap(&SubstTable[n1 & 0xFF], &SubstTable[(n1 + i + k) & 0xFF]);
- }
- for (UInt32 i = 0; i < passwordLen; i+= 16)
- EncryptBlock(&psw[i]);
-}
-
-void CData::CryptBlock(Byte *buf, bool encrypt)
-{
- Byte inBuf[16];
- UInt32 A, B, C, D, T, TA, TB;
-
- A = GetUi32(buf + 0) ^ Keys[0];
- B = GetUi32(buf + 4) ^ Keys[1];
- C = GetUi32(buf + 8) ^ Keys[2];
- D = GetUi32(buf + 12) ^ Keys[3];
-
- if (!encrypt)
- memcpy(inBuf, buf, sizeof(inBuf));
-
- for (int i = 0; i < kNumRounds; i++)
- {
- UInt32 key = Keys[(encrypt ? i : (kNumRounds - 1 - i)) & 3];
- T = ((C + rotlFixed(D, 11)) ^ key);
- TA = A ^ SubstLong(T);
- T = ((D ^ rotlFixed(C, 17)) + key);
- TB = B ^ SubstLong(T);
- A = C;
- B = D;
- C = TA;
- D = TB;
- }
-
- SetUi32(buf + 0, C ^ Keys[0]);
- SetUi32(buf + 4, D ^ Keys[1]);
- SetUi32(buf + 8, A ^ Keys[2]);
- SetUi32(buf + 12, B ^ Keys[3]);
-
- UpdateKeys(encrypt ? buf : inBuf);
-}
-
-STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- _cipher.SetPassword(data, size);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::Init()
-{
- return S_OK;
-}
-
-static const UInt32 kBlockSize = 16;
-
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- if (size == 0)
- return 0;
- if (size < kBlockSize)
- return kBlockSize;
- UInt32 i;
- size -= kBlockSize;
- for (i = 0; i <= size; i += kBlockSize)
- _cipher.DecryptBlock(data + i);
- return i;
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h
deleted file mode 100644
index b9648f59d..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Rar20Crypto.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Crypto/Rar20Crypto.h
-
-#ifndef __CRYPTO_RAR20_CRYPTO_H
-#define __CRYPTO_RAR20_CRYPTO_H
-
-#include "Common/MyCom.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-namespace NCrypto {
-namespace NRar20 {
-
-class CData
-{
- Byte SubstTable[256];
- UInt32 Keys[4];
-
- UInt32 SubstLong(UInt32 t)
- {
- return (UInt32)SubstTable[(int)t & 255] |
- ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
- ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
- ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
- }
- void UpdateKeys(const Byte *data);
- void CryptBlock(Byte *buf, bool encrypt);
-public:
- void EncryptBlock(Byte *buf) { CryptBlock(buf, true); }
- void DecryptBlock(Byte *buf) { CryptBlock(buf, false); }
- void SetPassword(const Byte *password, UInt32 passwordLen);
-};
-
-class CDecoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp
-{
- CData _cipher;
-public:
- MY_UNKNOWN_IMP1(ICryptoSetPassword)
-
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp
deleted file mode 100644
index bbb4ccefb..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// Crypto/RarAes.cpp
-// Note: you must include MyAes.cpp to project to initialize AES tables
-
-#include "StdAfx.h"
-
-#include "RarAes.h"
-#include "Sha1.h"
-
-namespace NCrypto {
-namespace NRar29 {
-
-CDecoder::CDecoder():
- _thereIsSalt(false),
- _needCalculate(true),
- _rar350Mode(false)
-{
- for (int i = 0; i < sizeof(_salt); i++)
- _salt[i] = 0;
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- bool thereIsSaltPrev = _thereIsSalt;
- _thereIsSalt = false;
- if (size == 0)
- return S_OK;
- if (size < 8)
- return E_INVALIDARG;
- _thereIsSalt = true;
- bool same = false;
- if (_thereIsSalt == thereIsSaltPrev)
- {
- same = true;
- if (_thereIsSalt)
- {
- for (int i = 0; i < sizeof(_salt); i++)
- if (_salt[i] != data[i])
- {
- same = false;
- break;
- }
- }
- }
- for (int i = 0; i < sizeof(_salt); i++)
- _salt[i] = data[i];
- if (!_needCalculate && !same)
- _needCalculate = true;
- return S_OK;
-}
-
-static const int kMaxPasswordLength = 127 * 2;
-
-STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- if (size > kMaxPasswordLength)
- size = kMaxPasswordLength;
- bool same = false;
- if (size == buffer.GetCapacity())
- {
- same = true;
- for (UInt32 i = 0; i < size; i++)
- if (data[i] != buffer[i])
- {
- same = false;
- break;
- }
- }
- if (!_needCalculate && !same)
- _needCalculate = true;
- buffer.SetCapacity(size);
- memcpy(buffer, data, size);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::Init()
-{
- Calculate();
- Aes_SetKeyDecode(&Aes.aes, aesKey, kRarAesKeySize);
- AesCbc_Init(&Aes, aesInit);
- return S_OK;
-}
-
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- return (UInt32)AesCbc_Decode(&Aes, data, size);
-}
-
-void CDecoder::Calculate()
-{
- if (_needCalculate)
- {
- const int kSaltSize = 8;
-
- Byte rawPassword[kMaxPasswordLength + kSaltSize];
-
- memcpy(rawPassword, buffer, buffer.GetCapacity());
-
- size_t rawLength = buffer.GetCapacity();
-
- if (_thereIsSalt)
- {
- memcpy(rawPassword + rawLength, _salt, kSaltSize);
- rawLength += kSaltSize;
- }
-
- NSha1::CContext sha;
- sha.Init();
-
- // seems rar reverts hash for sha.
- const int hashRounds = 0x40000;
- int i;
- for (i = 0; i < hashRounds; i++)
- {
- sha.Update(rawPassword, rawLength, _rar350Mode);
- Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
- sha.Update(pswNum, 3, _rar350Mode);
- if (i % (hashRounds / 16) == 0)
- {
- NSha1::CContext shaTemp = sha;
- Byte digest[NSha1::kDigestSize];
- shaTemp.Final(digest);
- aesInit[i / (hashRounds / 16)] = (Byte)digest[4 * 4 + 3];
- }
- }
- /*
- // it's test message for sha
- const char *message = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
- sha.Update((const Byte *)message, strlen(message));
- */
- Byte digest[20];
- sha.Final(digest);
- for (i = 0; i < 4; i++)
- for (int j = 0; j < 4; j++)
- aesKey[i * 4 + j] = (digest[i * 4 + 3 - j]);
- }
- _needCalculate = false;
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h
deleted file mode 100644
index 374017b84..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/RarAes.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Crypto/RarAes.h
-
-#ifndef __CRYPTO_RAR_AES_H
-#define __CRYPTO_RAR_AES_H
-
-#include "../../../C/Aes.h"
-
-#include "Common/Buffer.h"
-#include "Common/MyCom.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-namespace NCrypto {
-namespace NRar29 {
-
-const UInt32 kRarAesKeySize = 16;
-
-class CDecoder:
- public ICompressFilter,
- public ICompressSetDecoderProperties2,
- public ICryptoSetPassword,
- public CMyUnknownImp
-{
- Byte _salt[8];
- bool _thereIsSalt;
- CByteBuffer buffer;
- Byte aesKey[kRarAesKeySize];
- Byte aesInit[AES_BLOCK_SIZE];
- bool _needCalculate;
-
- CAesCbc Aes;
-
- bool _rar350Mode;
-
- void Calculate();
-
-public:
-
- MY_UNKNOWN_IMP2(
- ICryptoSetPassword,
- ICompressSetDecoderProperties2)
-
- STDMETHOD(Init)();
-
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
-
- STDMETHOD(CryptoSetPassword)(const Byte *aData, UInt32 aSize);
-
- // ICompressSetDecoderProperties
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
-
- CDecoder();
- void SetRar350Mode(bool rar350Mode) { _rar350Mode = rar350Mode; }
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp
deleted file mode 100644
index 92174d18b..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-// Crypto/Sha1.cpp
-// This file is based on public domain
-// Steve Reid and Wei Dai's code from Crypto++
-
-#include "StdAfx.h"
-
-#include "../../../C/RotateDefs.h"
-
-#include "Sha1.h"
-
-namespace NCrypto {
-namespace NSha1 {
-
-// define it for speed optimization
-// #define _SHA1_UNROLL
-
-static const unsigned kNumW =
- #ifdef _SHA1_UNROLL
- 16;
- #else
- 80;
- #endif
-
-
-#define w0(i) (W[(i)] = data[(i)])
-
-#ifdef _SHA1_UNROLL
-#define w1(i) (W[(i)&15] = rotlFixed(W[((i)-3)&15] ^ W[((i)-8)&15] ^ W[((i)-14)&15] ^ W[((i)-16)&15], 1))
-#else
-#define w1(i) (W[(i)] = rotlFixed(W[(i)-3] ^ W[(i)-8] ^ W[(i)-14] ^ W[(i)-16], 1))
-#endif
-
-#define f1(x,y,z) (z^(x&(y^z)))
-#define f2(x,y,z) (x^y^z)
-#define f3(x,y,z) ((x&y)|(z&(x|y)))
-#define f4(x,y,z) (x^y^z)
-
-#define RK1(a,b,c,d,e,i, f, w, k) e += f(b,c,d) + w(i) + k + rotlFixed(a,5); b = rotlFixed(b,30);
-
-#define R0(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w0, 0x5A827999)
-#define R1(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f1, w1, 0x5A827999)
-#define R2(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f2, w1, 0x6ED9EBA1)
-#define R3(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f3, w1, 0x8F1BBCDC)
-#define R4(a,b,c,d,e,i) RK1(a,b,c,d,e,i, f4, w1, 0xCA62C1D6)
-
-#define RX_1_4(rx1, rx4, i) rx1(a,b,c,d,e,i); rx4(e,a,b,c,d,i+1); rx4(d,e,a,b,c,i+2); rx4(c,d,e,a,b,i+3); rx4(b,c,d,e,a,i+4);
-#define RX_5(rx, i) RX_1_4(rx, rx, i);
-
-void CContextBase::Init()
-{
- _state[0] = 0x67452301;
- _state[1] = 0xEFCDAB89;
- _state[2] = 0x98BADCFE;
- _state[3] = 0x10325476;
- _state[4] = 0xC3D2E1F0;
- _count = 0;
-}
-
-void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnRes)
-{
- UInt32 a, b, c, d, e;
- UInt32 W[kNumW];
-
- a = _state[0];
- b = _state[1];
- c = _state[2];
- d = _state[3];
- e = _state[4];
- #ifdef _SHA1_UNROLL
- RX_5(R0, 0); RX_5(R0, 5); RX_5(R0, 10);
- #else
- int i;
- for (i = 0; i < 15; i += 5) { RX_5(R0, i); }
- #endif
-
- RX_1_4(R0, R1, 15);
-
-
- #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);
- #else
- i = 20;
- for (; i < 40; i += 5) { RX_5(R2, i); }
- for (; i < 60; i += 5) { RX_5(R3, i); }
- for (; i < 80; i += 5) { RX_5(R4, i); }
- #endif
-
- destDigest[0] = _state[0] + a;
- destDigest[1] = _state[1] + b;
- destDigest[2] = _state[2] + c;
- destDigest[3] = _state[3] + d;
- destDigest[4] = _state[4] + e;
-
- if (returnRes)
- for (int i = 0 ; i < 16; i++)
- data[i] = W[kNumW - 16 + i];
-
- // Wipe variables
- // a = b = c = d = e = 0;
-}
-
-void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
-{
- unsigned curBufferPos = size & 0xF;
- block[curBufferPos++] = 0x80000000;
- while (curBufferPos != (16 - 2))
- block[curBufferPos++] = 0;
- const UInt64 lenInBits = (_count << 9) + ((UInt64)size << 5);
- block[curBufferPos++] = (UInt32)(lenInBits >> 32);
- block[curBufferPos++] = (UInt32)(lenInBits);
-}
-
-void CContext::Update(Byte *data, size_t size, bool rar350Mode)
-{
- bool returnRes = false;
- unsigned curBufferPos = _count2;
- while (size-- > 0)
- {
- int pos = (int)(curBufferPos & 3);
- if (pos == 0)
- _buffer[curBufferPos >> 2] = 0;
- _buffer[curBufferPos >> 2] |= ((UInt32)*data++) << (8 * (3 - pos));
- if (++curBufferPos == kBlockSize)
- {
- curBufferPos = 0;
- CContextBase::UpdateBlock(_buffer, returnRes);
- if (returnRes)
- for (unsigned int i = 0; i < kBlockSizeInWords; i++)
- {
- UInt32 d = _buffer[i];
- data[i * 4 + 0 - kBlockSize] = (Byte)(d);
- data[i * 4 + 1 - kBlockSize] = (Byte)(d >> 8);
- data[i * 4 + 2 - kBlockSize] = (Byte)(d >> 16);
- data[i * 4 + 3 - kBlockSize] = (Byte)(d >> 24);
- }
- returnRes = rar350Mode;
- }
- }
- _count2 = curBufferPos;
-}
-
-void CContext::Final(Byte *digest)
-{
- const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 3);
- unsigned curBufferPos = _count2;
- int pos = (int)(curBufferPos & 3);
- curBufferPos >>= 2;
- if (pos == 0)
- _buffer[curBufferPos] = 0;
- _buffer[curBufferPos++] |= ((UInt32)0x80) << (8 * (3 - pos));
-
- while (curBufferPos != (16 - 2))
- {
- curBufferPos &= 0xF;
- if (curBufferPos == 0)
- UpdateBlock();
- _buffer[curBufferPos++] = 0;
- }
- _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
- _buffer[curBufferPos++] = (UInt32)(lenInBits);
- UpdateBlock();
-
- unsigned int i;
- for (i = 0; i < kDigestSizeInWords; i++)
- {
- UInt32 state = _state[i] & 0xFFFFFFFF;
- *digest++ = (Byte)(state >> 24);
- *digest++ = (Byte)(state >> 16);
- *digest++ = (Byte)(state >> 8);
- *digest++ = (Byte)(state);
- }
- Init();
-}
-
-///////////////////////////
-// Words version
-
-void CContext32::Update(const UInt32 *data, size_t size)
-{
- while (size-- > 0)
- {
- _buffer[_count2++] = *data++;
- if (_count2 == kBlockSizeInWords)
- {
- _count2 = 0;
- UpdateBlock();
- }
- }
-}
-
-void CContext32::Final(UInt32 *digest)
-{
- const UInt64 lenInBits = (_count << 9) + ((UInt64)_count2 << 5);
- unsigned curBufferPos = _count2;
- _buffer[curBufferPos++] = 0x80000000;
- while (curBufferPos != (16 - 2))
- {
- curBufferPos &= 0xF;
- if (curBufferPos == 0)
- UpdateBlock();
- _buffer[curBufferPos++] = 0;
- }
- _buffer[curBufferPos++] = (UInt32)(lenInBits >> 32);
- _buffer[curBufferPos++] = (UInt32)(lenInBits);
- GetBlockDigest(_buffer, digest);
- Init();
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h
deleted file mode 100644
index 405be2166..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/Sha1.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Crypto/Sha1.h
-// This file is based on public domain
-// Steve Reid and Wei Dai's code from Crypto++
-
-#ifndef __CRYPTO_SHA1_H
-#define __CRYPTO_SHA1_H
-
-#include <stddef.h>
-#include "../../Common/Types.h"
-
-// Sha1 implementation in RAR before version 3.60 has bug:
-// it changes data bytes in some cases.
-// So this class supports both versions: normal_SHA and rar3Mode
-
-namespace NCrypto {
-namespace NSha1 {
-
-const unsigned kBlockSize = 64;
-const unsigned kDigestSize = 20;
-
-const unsigned kBlockSizeInWords = (kBlockSize >> 2);
-const unsigned kDigestSizeInWords = (kDigestSize >> 2);
-
-class CContextBase
-{
-protected:
- UInt32 _state[5];
- UInt64 _count;
- void UpdateBlock(UInt32 *data, bool returnRes = false)
- {
- GetBlockDigest(data, _state, returnRes);
- _count++;
- }
-public:
- void Init();
- void GetBlockDigest(UInt32 *blockData, UInt32 *destDigest, bool returnRes = false);
- // PrepareBlock can be used only when size <= 13. size in Words
- void PrepareBlock(UInt32 *block, unsigned int size) const;
-};
-
-class CContextBase2: public CContextBase
-{
-protected:
- unsigned _count2;
- UInt32 _buffer[kBlockSizeInWords];
- void UpdateBlock() { CContextBase::UpdateBlock(_buffer); }
-public:
- void Init() { CContextBase::Init(); _count2 = 0; }
-};
-
-class CContext: public CContextBase2
-{
-public:
- void Update(Byte *data, size_t size, bool rar350Mode = false);
- void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); }
- void Final(Byte *digest);
-};
-
-class CContext32: public CContextBase2
-{
-public:
- void Update(const UInt32 *data, size_t size);
- void Final(UInt32 *digest);
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp
deleted file mode 100644
index beb24217c..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-// Crypto/WzAes.cpp
-/*
-This code implements Brian Gladman's scheme
-specified in password Based File Encryption Utility.
-
-Note: you must include MyAes.cpp to project to initialize AES tables
-*/
-
-#include "StdAfx.h"
-
-#include "../Common/StreamObjects.h"
-#include "../Common/StreamUtils.h"
-
-#include "Pbkdf2HmacSha1.h"
-#include "RandGen.h"
-#include "WzAes.h"
-
-// define it if you don't want to use speed-optimized version of Pbkdf2HmacSha1
-// #define _NO_WZAES_OPTIMIZATIONS
-
-namespace NCrypto {
-namespace NWzAes {
-
-const unsigned int kAesKeySizeMax = 32;
-
-static const UInt32 kNumKeyGenIterations = 1000;
-
-STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- if(size > kPasswordSizeMax)
- return E_INVALIDARG;
- _key.Password.SetCapacity(size);
- memcpy(_key.Password, data, size);
- return S_OK;
-}
-
-#define SetUi32(p, d) { UInt32 x = (d); (p)[0] = (Byte)x; (p)[1] = (Byte)(x >> 8); \
- (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];
- Aes_Encode32(&Aes, temp, _counter);
- SetUi32(_buffer, temp[0]);
- SetUi32(_buffer + 4, temp[1]);
- SetUi32(_buffer + 8, temp[2]);
- SetUi32(_buffer + 12, temp[3]);
- pos = 0;
- }
- *data++ ^= _buffer[pos++];
- }
- _blockPos = pos;
-}
-
-#ifndef _NO_WZAES_OPTIMIZATIONS
-
-static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize)
-{
- for (int i = 0 ; i < destSize; i++)
- dest[i] =
- ((UInt32)(src[i * 4 + 0]) << 24) |
- ((UInt32)(src[i * 4 + 1]) << 16) |
- ((UInt32)(src[i * 4 + 2]) << 8) |
- ((UInt32)(src[i * 4 + 3]));
-}
-
-#endif
-
-STDMETHODIMP CBaseCoder::Init()
-{
- UInt32 keySize = _key.GetKeySize();
- UInt32 keysTotalSize = 2 * keySize + kPwdVerifCodeSize;
- Byte buf[2 * kAesKeySizeMax + kPwdVerifCodeSize];
-
- // for (int ii = 0; ii < 1000; ii++)
- {
- #ifdef _NO_WZAES_OPTIMIZATIONS
-
- NSha1::Pbkdf2Hmac(
- _key.Password, _key.Password.GetCapacity(),
- _key.Salt, _key.GetSaltSize(),
- kNumKeyGenIterations,
- buf, keysTotalSize);
-
- #else
-
- UInt32 buf32[(2 * kAesKeySizeMax + kPwdVerifCodeSize + 3) / 4];
- UInt32 key32SizeTotal = (keysTotalSize + 3) / 4;
- UInt32 salt[kSaltSizeMax * 4];
- UInt32 saltSizeInWords = _key.GetSaltSize() / 4;
- BytesToBeUInt32s(_key.Salt, salt, saltSizeInWords);
- NSha1::Pbkdf2Hmac32(
- _key.Password, _key.Password.GetCapacity(),
- salt, saltSizeInWords,
- kNumKeyGenIterations,
- buf32, key32SizeTotal);
- for (UInt32 j = 0; j < keysTotalSize; j++)
- buf[j] = (Byte)(buf32[j / 4] >> (24 - 8 * (j & 3)));
-
- #endif
- }
-
- _hmac.SetKey(buf + keySize, keySize);
- memcpy(_key.PwdVerifComputed, buf + 2 * keySize, kPwdVerifCodeSize);
-
- _blockPos = AES_BLOCK_SIZE;
- for (int i = 0; i < 4; i++)
- _counter[i] = 0;
-
- Aes_SetKeyEncode(&Aes, buf, keySize);
- return S_OK;
-}
-
-/*
-STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
- Byte keySizeMode = 3;
- return outStream->Write(&keySizeMode, 1, NULL);
-}
-*/
-
-HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
-{
- UInt32 saltSize = _key.GetSaltSize();
- g_RandomGenerator.Generate(_key.Salt, saltSize);
- Init();
- RINOK(WriteStream(outStream, _key.Salt, saltSize));
- return WriteStream(outStream, _key.PwdVerifComputed, kPwdVerifCodeSize);
-}
-
-HRESULT CEncoder::WriteFooter(ISequentialOutStream *outStream)
-{
- Byte mac[kMacSize];
- _hmac.Final(mac, kMacSize);
- return WriteStream(outStream, mac, kMacSize);
-}
-
-STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
-{
- if (size != 1)
- return E_INVALIDARG;
- _key.Init();
- Byte keySizeMode = data[0];
- if (keySizeMode < 1 || keySizeMode > 3)
- return E_INVALIDARG;
- _key.KeySizeMode = keySizeMode;
- return S_OK;
-}
-
-HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
-{
- UInt32 saltSize = _key.GetSaltSize();
- UInt32 extraSize = saltSize + kPwdVerifCodeSize;
- Byte temp[kSaltSizeMax + kPwdVerifCodeSize];
- RINOK(ReadStream_FAIL(inStream, temp, extraSize));
- UInt32 i;
- for (i = 0; i < saltSize; i++)
- _key.Salt[i] = temp[i];
- for (i = 0; i < kPwdVerifCodeSize; i++)
- _pwdVerifFromArchive[i] = temp[saltSize + i];
- return S_OK;
-}
-
-static bool CompareArrays(const Byte *p1, const Byte *p2, UInt32 size)
-{
- for (UInt32 i = 0; i < size; i++)
- if (p1[i] != p2[i])
- return false;
- return true;
-}
-
-bool CDecoder::CheckPasswordVerifyCode()
-{
- return CompareArrays(_key.PwdVerifComputed, _pwdVerifFromArchive, kPwdVerifCodeSize);
-}
-
-HRESULT CDecoder::CheckMac(ISequentialInStream *inStream, bool &isOK)
-{
- isOK = false;
- Byte mac1[kMacSize];
- RINOK(ReadStream_FAIL(inStream, mac1, kMacSize));
- Byte mac2[kMacSize];
- _hmac.Final(mac2, kMacSize);
- isOK = CompareArrays(mac1, mac2, kMacSize);
- return S_OK;
-}
-
-STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
-{
- EncryptData(data, size);
- _hmac.Update(data, size);
- return size;
-}
-
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- _hmac.Update(data, size);
- EncryptData(data, size);
- return size;
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h
deleted file mode 100644
index 22f4d4dd3..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/WzAes.h
+++ /dev/null
@@ -1,116 +0,0 @@
-// Crypto/WzAes.h
-/*
-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
- Salt (saltSize = aesKeySize / 2).
- - 2 bytes contain Password Verifier's Code
-*/
-
-#ifndef __CRYPTO_WZ_AES_H
-#define __CRYPTO_WZ_AES_H
-
-#include "../../../C/Aes.h"
-
-#include "Common/Buffer.h"
-#include "Common/MyCom.h"
-#include "Common/MyVector.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-#include "HmacSha1.h"
-
-namespace NCrypto {
-namespace NWzAes {
-
-const unsigned int kSaltSizeMax = 16;
-const unsigned int kMacSize = 10;
-
-const UInt32 kPasswordSizeMax = 99; // 128;
-
-// Password Verification Code Size
-const unsigned int kPwdVerifCodeSize = 2;
-
-class CKeyInfo
-{
-public:
- Byte KeySizeMode; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
- Byte Salt[kSaltSizeMax];
- Byte PwdVerifComputed[kPwdVerifCodeSize];
-
- CByteBuffer Password;
-
- UInt32 GetKeySize() const { return (8 * (KeySizeMode & 3) + 8); }
- UInt32 GetSaltSize() const { return (4 * (KeySizeMode & 3) + 4); }
-
- CKeyInfo() { Init(); }
- void Init() { KeySizeMode = 3; }
-};
-
-class CBaseCoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp
-{
-protected:
- CKeyInfo _key;
- UInt32 _counter[AES_BLOCK_SIZE / 4];
- Byte _buffer[AES_BLOCK_SIZE];
- NSha1::CHmac _hmac;
- unsigned int _blockPos;
- Byte _pwdVerifFromArchive[kPwdVerifCodeSize];
-
- void EncryptData(Byte *data, UInt32 size);
-
- CAes Aes;
-
-public:
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
-
- STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
-
- UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; }
-};
-
-class CEncoder:
- public CBaseCoder
- // public ICompressWriteCoderProperties
-{
-public:
- MY_UNKNOWN_IMP1(ICryptoSetPassword)
- // ICompressWriteCoderProperties
- // STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- HRESULT WriteHeader(ISequentialOutStream *outStream);
- HRESULT WriteFooter(ISequentialOutStream *outStream);
- bool SetKeyMode(Byte mode)
- {
- if (mode < 1 || mode > 3)
- return false;
- _key.KeySizeMode = mode;
- return true;
- }
-};
-
-class CDecoder:
- public CBaseCoder,
- public ICompressSetDecoderProperties2
-{
-public:
- MY_UNKNOWN_IMP2(
- ICryptoSetPassword,
- ICompressSetDecoderProperties2)
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
- HRESULT ReadHeader(ISequentialInStream *inStream);
- bool CheckPasswordVerifyCode();
- HRESULT CheckMac(ISequentialInStream *inStream, bool &isOK);
-};
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp
deleted file mode 100644
index f5972c572..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-// Crypto/ZipCrypto.cpp
-
-#include "StdAfx.h"
-
-#include "../../../C/7zCrc.h"
-
-#include "../Common/StreamUtils.h"
-
-#include "RandGen.h"
-#include "ZipCrypto.h"
-
-namespace NCrypto {
-namespace NZip {
-
-void CCipher::UpdateKeys(Byte b)
-{
- Keys[0] = CRC_UPDATE_BYTE(Keys[0], b);
- Keys[1] += Keys[0] & 0xff;
- Keys[1] = Keys[1] * 134775813L + 1;
- Keys[2] = CRC_UPDATE_BYTE(Keys[2], (Byte)(Keys[1] >> 24));
-}
-
-void CCipher::SetPassword(const Byte *password, UInt32 passwordLen)
-{
- Keys[0] = 305419896L;
- Keys[1] = 591751049L;
- Keys[2] = 878082192L;
- for (UInt32 i = 0; i < passwordLen; i++)
- UpdateKeys(password[i]);
-}
-
-Byte CCipher::DecryptByteSpec()
-{
- UInt32 temp = Keys[2] | 2;
- return (Byte)((temp * (temp ^ 1)) >> 8);
-}
-
-Byte CCipher::DecryptByte(Byte b)
-{
- Byte c = (Byte)(b ^ DecryptByteSpec());
- UpdateKeys(c);
- return c;
-}
-
-Byte CCipher::EncryptByte(Byte b)
-{
- Byte c = (Byte)(b ^ DecryptByteSpec());
- UpdateKeys(b);
- return c;
-}
-
-void CCipher::DecryptHeader(Byte *buf)
-{
- for (unsigned i = 0; i < kHeaderSize; i++)
- buf[i] = DecryptByte(buf[i]);
-}
-
-void CCipher::EncryptHeader(Byte *buf)
-{
- for (unsigned i = 0; i < kHeaderSize; i++)
- buf[i] = EncryptByte(buf[i]);
-}
-
-STDMETHODIMP CEncoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- _cipher.SetPassword(data, size);
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::CryptoSetCRC(UInt32 crc)
-{
- _crc = crc;
- return S_OK;
-}
-
-STDMETHODIMP CEncoder::Init()
-{
- return S_OK;
-}
-
-HRESULT CEncoder::WriteHeader(ISequentialOutStream *outStream)
-{
- Byte header[kHeaderSize];
- g_RandomGenerator.Generate(header, kHeaderSize - 2);
-
- header[kHeaderSize - 1] = Byte(_crc >> 24);
- header[kHeaderSize - 2] = Byte(_crc >> 16);
-
- _cipher.EncryptHeader(header);
- return WriteStream(outStream, header, kHeaderSize);
-}
-
-STDMETHODIMP_(UInt32) CEncoder::Filter(Byte *data, UInt32 size)
-{
- UInt32 i;
- for (i = 0; i < size; i++)
- data[i] = _cipher.EncryptByte(data[i]);
- return i;
-}
-
-STDMETHODIMP CDecoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- _cipher.SetPassword(data, size);
- return S_OK;
-}
-
-HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream)
-{
- Byte header[kHeaderSize];
- RINOK(ReadStream_FAIL(inStream, header, kHeaderSize));
- _cipher.DecryptHeader(header);
- return S_OK;
-}
-
-STDMETHODIMP CDecoder::Init()
-{
- return S_OK;
-}
-
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- UInt32 i;
- for (i = 0; i < size; i++)
- data[i] = _cipher.DecryptByte(data[i]);
- return i;
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h
deleted file mode 100644
index 040ebb095..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipCrypto.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// Crypto/ZipCrypto.h
-
-#ifndef __CRYPTO_ZIP_CRYPTO_H
-#define __CRYPTO_ZIP_CRYPTO_H
-
-#include "Common/MyCom.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-namespace NCrypto {
-namespace NZip {
-
-const unsigned kHeaderSize = 12;
-
-class CCipher
-{
- UInt32 Keys[3];
-
- void UpdateKeys(Byte b);
- Byte DecryptByteSpec();
-public:
- void SetPassword(const Byte *password, UInt32 passwordLen);
- Byte DecryptByte(Byte b);
- Byte EncryptByte(Byte b);
- void DecryptHeader(Byte *buf);
- void EncryptHeader(Byte *buf);
-};
-
-class CEncoder :
- public ICompressFilter,
- public ICryptoSetPassword,
- public ICryptoSetCRC,
- public CMyUnknownImp
-{
- CCipher _cipher;
- UInt32 _crc;
-public:
- MY_UNKNOWN_IMP2(
- ICryptoSetPassword,
- ICryptoSetCRC
- )
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
-
- STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
- STDMETHOD(CryptoSetCRC)(UInt32 crc);
- HRESULT WriteHeader(ISequentialOutStream *outStream);
-};
-
-
-class CDecoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp
-{
- CCipher _cipher;
-public:
- MY_UNKNOWN_IMP1(ICryptoSetPassword)
-
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
-
- HRESULT ReadHeader(ISequentialInStream *inStream);
-};
-
-
-}}
-
-#endif
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp
deleted file mode 100644
index be5b42754..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// Crypto/ZipStrong.cpp
-
-#include "StdAfx.h"
-
-#include "../../../C/7zCrc.h"
-#include "../../../C/CpuArch.h"
-
-#include "../Common/StreamUtils.h"
-
-#include "MyAes.h"
-#include "Sha1.h"
-#include "ZipStrong.h"
-
-namespace NCrypto {
-namespace NZipStrong {
-
-static const UInt16 kAES128 = 0x660E;
-
-// DeriveKey* function is similar to CryptDeriveKey() from Windows.
-// But MSDN tells that we need such scheme only if
-// "the required key length is longer than the hash value"
-// but ZipStrong uses it always.
-
-static void DeriveKey2(const Byte *digest, Byte c, Byte *dest)
-{
- Byte buf[64];
- memset(buf, c, 64);
- for (unsigned i = 0; i < NSha1::kDigestSize; i++)
- buf[i] ^= digest[i];
- NSha1::CContext sha;
- sha.Init();
- sha.Update(buf, 64);
- sha.Final(dest);
-}
-
-static void DeriveKey(NSha1::CContext &sha, Byte *key)
-{
- Byte digest[NSha1::kDigestSize];
- sha.Final(digest);
- Byte temp[NSha1::kDigestSize * 2];
- DeriveKey2(digest, 0x36, temp);
- DeriveKey2(digest, 0x5C, temp + NSha1::kDigestSize);
- memcpy(key, temp, 32);
-}
-
-void CKeyInfo::SetPassword(const Byte *data, UInt32 size)
-{
- NSha1::CContext sha;
- sha.Init();
- sha.Update(data, size);
- DeriveKey(sha, MasterKey);
-}
-
-STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
-{
- _key.SetPassword(data, size);
- return S_OK;
-}
-
-STDMETHODIMP CBaseCoder::Init()
-{
- return S_OK;
-}
-
-HRESULT CDecoder::ReadHeader(ISequentialInStream *inStream, UInt32 /* crc */, UInt64 /* unpackSize */)
-{
- Byte temp[4];
- RINOK(ReadStream_FALSE(inStream, temp, 2));
- _ivSize = GetUi16(temp);
- if (_ivSize == 0)
- {
- return E_NOTIMPL;
- /*
- SetUi32(_iv, crc);
- for (int i = 0; i < 8; i++)
- _iv[4 + i] = (Byte)(unpackSize >> (8 * i));
- SetUi32(_iv + 12, 0);
- */
- }
- else if (_ivSize == 16)
- {
- RINOK(ReadStream_FALSE(inStream, _iv, _ivSize));
- }
- else
- return E_NOTIMPL;
- RINOK(ReadStream_FALSE(inStream, temp, 4));
- _remSize = GetUi32(temp);
- if (_remSize > _buf.GetCapacity())
- {
- _buf.Free();
- _buf.SetCapacity(_remSize);
- }
- return ReadStream_FALSE(inStream, _buf, _remSize);
-}
-
-HRESULT CDecoder::CheckPassword(bool &passwOK)
-{
- passwOK = false;
- if (_remSize < 10)
- return E_NOTIMPL;
- Byte *p = _buf;
- UInt16 format = GetUi16(p);
- if (format != 3)
- return E_NOTIMPL;
- UInt16 algId = GetUi16(p + 2);
- if (algId < kAES128)
- return E_NOTIMPL;
- algId -= kAES128;
- if (algId > 2)
- return E_NOTIMPL;
- UInt16 bitLen = GetUi16(p + 4);
- UInt16 flags = GetUi16(p + 6);
- if (algId * 64 + 128 != bitLen)
- return E_NOTIMPL;
- _key.KeySize = 16 + algId * 8;
- if ((flags & 1) == 0)
- return E_NOTIMPL;
- UInt32 rdSize = GetUi16(p + 8);
- UInt32 pos = 10;
- Byte *rd = p + pos;
- pos += rdSize;
- if (pos + 4 > _remSize)
- return E_NOTIMPL;
- UInt32 reserved = GetUi32(p + pos);
- pos += 4;
- if (reserved != 0)
- return E_NOTIMPL;
- if (pos + 2 > _remSize)
- return E_NOTIMPL;
- UInt32 validSize = GetUi16(p + pos);
- pos += 2;
- Byte *validData = p + pos;
- if (pos + validSize != _remSize)
- return E_NOTIMPL;
-
- if (!_aesFilter)
- _aesFilter = new CAesCbcDecoder;
-
- CMyComPtr<ICryptoProperties> cp;
- RINOK(_aesFilter.QueryInterface(IID_ICryptoProperties, &cp));
- {
- RINOK(cp->SetKey(_key.MasterKey, _key.KeySize));
- RINOK(cp->SetInitVector(_iv, 16));
- _aesFilter->Init();
- if (_aesFilter->Filter(rd, rdSize) != rdSize)
- return E_NOTIMPL;
- }
-
- Byte fileKey[32];
- NSha1::CContext sha;
- sha.Init();
- sha.Update(_iv, 16);
- sha.Update(rd, rdSize - 16); // we don't use last 16 bytes (PAD bytes)
- DeriveKey(sha, fileKey);
-
- RINOK(cp->SetKey(fileKey, _key.KeySize));
- RINOK(cp->SetInitVector(_iv, 16));
- _aesFilter->Init();
- if (_aesFilter->Filter(validData, validSize) != validSize)
- return E_NOTIMPL;
-
- if (validSize < 4)
- return E_NOTIMPL;
- validSize -= 4;
- if (GetUi32(validData + validSize) != CrcCalc(validData, validSize))
- return S_OK;
- passwOK = true;
- _aesFilter->Init();
- return S_OK;
-}
-
-STDMETHODIMP_(UInt32) CDecoder::Filter(Byte *data, UInt32 size)
-{
- return _aesFilter->Filter(data, size);
-}
-
-}}
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h
deleted file mode 100644
index 6ea00b344..000000000
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/Crypto/ZipStrong.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Crypto/ZipStrong.h
-
-#ifndef __CRYPTO_ZIP_STRONG_H
-#define __CRYPTO_ZIP_STRONG_H
-
-#include "Common/MyCom.h"
-#include "Common/Buffer.h"
-
-#include "../ICoder.h"
-#include "../IPassword.h"
-
-namespace NCrypto {
-namespace NZipStrong {
-
-struct CKeyInfo
-{
- Byte MasterKey[32];
- UInt32 KeySize;
- void SetPassword(const Byte *data, UInt32 size);
-};
-
-class CBaseCoder:
- public ICompressFilter,
- public ICryptoSetPassword,
- public CMyUnknownImp
-{
-protected:
- CKeyInfo _key;
- CMyComPtr<ICompressFilter> _aesFilter;
- CByteBuffer _buf;
-public:
- STDMETHOD(Init)();
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) = 0;
-
- STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
-};
-
-class CDecoder:
- public CBaseCoder
-{
- UInt32 _ivSize;
- Byte _iv[16];
- UInt32 _remSize;
-public:
- MY_UNKNOWN_IMP1(ICryptoSetPassword)
- STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
- HRESULT ReadHeader(ISequentialInStream *inStream, UInt32 crc, UInt64 unpackSize);
- HRESULT CheckPassword(bool &passwOK);
-};
-
-}}
-
-#endif