Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-06-26 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:52 +0300
commitfd8b1d78b496fe38193bf8c5e86af3b43f0b022d (patch)
tree5b1e3812ed4d8b6037e5035faf3b638849f618e2 /CPP/7zip/Crypto
parent0b33f700a66fcf7f55f92b92e0b3e5c7014d769a (diff)
4.48 beta
Diffstat (limited to 'CPP/7zip/Crypto')
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.cpp63
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.h19
-rwxr-xr-xCPP/7zip/Crypto/WzAES/WzAES.h2
3 files changed, 45 insertions, 39 deletions
diff --git a/CPP/7zip/Crypto/7zAES/7zAES.cpp b/CPP/7zip/Crypto/7zAES/7zAES.cpp
index ae9854e4..d8d86fab 100755
--- a/CPP/7zip/Crypto/7zAES/7zAES.cpp
+++ b/CPP/7zip/Crypto/7zAES/7zAES.cpp
@@ -1,4 +1,4 @@
-// 7z_AES.cpp
+// 7zAES.cpp
#include "StdAfx.h"
@@ -8,9 +8,12 @@
#include "../../Common/StreamUtils.h"
#include "../AES/MyAES.h"
#include "../Hash/Sha256.h"
-
#include "7zAES.h"
+#ifndef EXTRACT_ONLY
+#include "../Hash/RandGen.h"
+#endif
+
using namespace NWindows;
namespace NCrypto {
@@ -89,7 +92,8 @@ static CKeyInfoCache g_GlobalKeyCache(32);
static NSynchronization::CCriticalSection g_GlobalKeyCacheCriticalSection;
CBase::CBase():
- _cachedKeys(16)
+ _cachedKeys(16),
+ _ivSize(0)
{
for (int i = 0; i < sizeof(_iv); i++)
_iv[i] = 0;
@@ -111,40 +115,31 @@ void CBase::CalculateDigest()
}
}
+#ifndef EXTRACT_ONLY
/*
-static void GetRandomData(Byte *data)
+STDMETHODIMP CEncoder::ResetSalt()
{
- // 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;
+ _key.SaltSize = 4;
+ g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
+ return S_OK;
}
*/
+STDMETHODIMP CEncoder::ResetInitVector()
+{
+ _ivSize = 8;
+ g_RandomGenerator.Generate(_iv, _ivSize);
+ return S_OK;
+}
+
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
{
- _key.Init();
- for (UInt32 i = 0; i < sizeof(_iv); i++)
+ // _key.Init();
+ for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
_iv[i] = 0;
- _key.SaltSize = 0;
-
- // _key.SaltSize = 8;
- // GetRandomData(_key.Salt);
-
- int ivSize = 0;
+ UInt32 ivSize = _ivSize;
// _key.NumCyclesPower = 0x3F;
_key.NumCyclesPower = 18;
@@ -170,6 +165,14 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
return S_OK;
}
+HRESULT CEncoder::CreateFilter()
+{
+ _aesFilter = new CAES_CBC_Encoder;
+ return S_OK;
+}
+
+#endif
+
STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
{
_key.Init();
@@ -229,12 +232,6 @@ STDMETHODIMP_(UInt32) CBaseCoder::Filter(Byte *data, UInt32 size)
return _aesFilter->Filter(data, size);
}
-HRESULT CEncoder::CreateFilter()
-{
- _aesFilter = new CAES_CBC_Encoder;
- return S_OK;
-}
-
HRESULT CDecoder::CreateFilter()
{
_aesFilter = new CAES_CBC_Decoder;
diff --git a/CPP/7zip/Crypto/7zAES/7zAES.h b/CPP/7zip/Crypto/7zAES/7zAES.h
index e8cedccf..ce14e2a1 100755
--- a/CPP/7zip/Crypto/7zAES/7zAES.h
+++ b/CPP/7zip/Crypto/7zAES/7zAES.h
@@ -6,7 +6,7 @@
#include "Common/MyCom.h"
#include "Common/Types.h"
#include "Common/Buffer.h"
-#include "Common/Vector.h"
+#include "Common/MyVector.h"
#include "../../ICoder.h"
#include "../../IPassword.h"
@@ -55,7 +55,7 @@ class CBase
protected:
CKeyInfo _key;
Byte _iv[16];
- // int _ivSize;
+ UInt32 _ivSize;
void CalculateDigest();
CBase();
};
@@ -80,17 +80,26 @@ public:
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
};
+#ifndef EXTRACT_ONLY
+
class CEncoder:
public CBaseCoder,
- public ICompressWriteCoderProperties
+ public ICompressWriteCoderProperties,
+ // public ICryptoResetSalt,
+ public ICryptoResetInitVector
{
virtual HRESULT CreateFilter();
public:
- MY_UNKNOWN_IMP2(
+ MY_UNKNOWN_IMP3(
ICryptoSetPassword,
- ICompressWriteCoderProperties)
+ ICompressWriteCoderProperties,
+ // ICryptoResetSalt,
+ ICryptoResetInitVector)
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
+ // STDMETHOD(ResetSalt)();
+ STDMETHOD(ResetInitVector)();
};
+#endif
class CDecoder:
public CBaseCoder,
diff --git a/CPP/7zip/Crypto/WzAES/WzAES.h b/CPP/7zip/Crypto/WzAES/WzAES.h
index 81ca3f4c..10df3045 100755
--- a/CPP/7zip/Crypto/WzAES/WzAES.h
+++ b/CPP/7zip/Crypto/WzAES/WzAES.h
@@ -16,7 +16,7 @@ specified in password Based File Encryption Utility:
#include "Common/MyCom.h"
#include "Common/Buffer.h"
-#include "Common/Vector.h"
+#include "Common/MyVector.h"
#include "../../ICoder.h"
#include "../../IPassword.h"