mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 08:07:09 -06:00
Use RtlGenRandom() as an additional source of entropy
for CRandomGenerator::Init() and 16 bytes IV for AES.
This commit is contained in:
@@ -151,21 +151,10 @@ void CBase::PrepareKey()
|
||||
|
||||
#ifndef EXTRACT_ONLY
|
||||
|
||||
/*
|
||||
STDMETHODIMP CEncoder::ResetSalt()
|
||||
{
|
||||
_key.SaltSize = 4;
|
||||
g_RandomGenerator.Generate(_key.Salt, _key.SaltSize);
|
||||
return S_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
STDMETHODIMP CEncoder::ResetInitVector()
|
||||
{
|
||||
for (unsigned i = 0; i < sizeof(_iv); i++)
|
||||
_iv[i] = 0;
|
||||
_ivSize = 8;
|
||||
g_RandomGenerator.Generate(_iv, _ivSize);
|
||||
_ivSize = sizeof(_iv);
|
||||
g_RandomGenerator.Generate(_iv, sizeof(_iv));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -245,7 +234,6 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size)
|
||||
|| _key.NumCyclesPower == 0x3F) ? S_OK : E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <unistd.h>
|
||||
#define USE_POSIX_TIME
|
||||
#define USE_POSIX_TIME2
|
||||
#else
|
||||
# define RtlGenRandom SystemFunction036
|
||||
extern "C" BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
|
||||
#endif
|
||||
|
||||
#ifdef USE_POSIX_TIME
|
||||
@@ -39,6 +42,8 @@ void CRandomGenerator::Init()
|
||||
HASH_UPD(w);
|
||||
w = ::GetCurrentThreadId();
|
||||
HASH_UPD(w);
|
||||
if (RtlGenRandom(&w, sizeof(DWORD)))
|
||||
HASH_UPD(w);
|
||||
#else
|
||||
pid_t pid = getpid();
|
||||
HASH_UPD(pid);
|
||||
|
||||
Reference in New Issue
Block a user