VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Common/Dlgcode.c84
-rw-r--r--src/Common/Dlgcode.h1
-rw-r--r--src/Common/Progress.h9
-rw-r--r--src/ExpandVolume/DlgExpandVolume.cpp22
-rw-r--r--src/Format/Tcformat.cbin645430 -> 642784 bytes
5 files changed, 53 insertions, 63 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 4ffae65c..e3e70985 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -52,8 +52,9 @@
#include "Wipe.h"
#include "Xml.h"
#include "Xts.h"
#include "Boot/Windows/BootCommon.h"
+#include "Progress.h"
#ifdef TCMOUNT
#include "Mount/Mount.h"
#include "Mount/resource.h"
@@ -5408,8 +5409,9 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR);
SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel);
SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0);
+ SendMessage (hEntropyBar, PBM_SETSTATE, PBST_ERROR, 0);
return 1;
}
case WM_TIMER:
@@ -5420,29 +5422,9 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA
DWORD mouseEventsCounter;
RandpeekBytes (hwndDlg, randPool, sizeof (randPool), &mouseEventsCounter);
- /* conservative estimate: 1 mouse move event brings 1 bit of entropy
- * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848
- */
- if (mouseEntropyGathered == 0xFFFFFFFF)
- {
- mouseEventsInitialCount = mouseEventsCounter;
- mouseEntropyGathered = 0;
- }
- else
- {
- if ( mouseEntropyGathered < maxEntropyLevel
- && (mouseEventsCounter >= mouseEventsInitialCount)
- && (mouseEventsCounter - mouseEventsInitialCount) <= maxEntropyLevel)
- mouseEntropyGathered = mouseEventsCounter - mouseEventsInitialCount;
- else
- mouseEntropyGathered = maxEntropyLevel;
-
- SendMessage (hEntropyBar, PBM_SETPOS,
- (WPARAM) (mouseEntropyGathered),
- 0);
- }
+ ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered);
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
{
outputDispBuffer[0] = 0;
@@ -5617,8 +5599,9 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
SetCheckBox (hwndDlg, IDC_DISPLAY_POOL_CONTENTS, bDisplayPoolContents);
hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR);
SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel);
SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0);
+ SendMessage (hEntropyBar, PBM_SETSTATE, PBST_ERROR, 0);
#ifndef VOLFORMAT
if (Randinit ())
{
@@ -5647,29 +5630,9 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
DWORD mouseEventsCounter;
RandpeekBytes (hwndDlg, randPool, sizeof (randPool), &mouseEventsCounter);
- /* conservative estimate: 1 mouse move event brings 1 bit of entropy
- * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848
- */
- if (mouseEntropyGathered == 0xFFFFFFFF)
- {
- mouseEventsInitialCount = mouseEventsCounter;
- mouseEntropyGathered = 0;
- }
- else
- {
- if ( mouseEntropyGathered < maxEntropyLevel
- && (mouseEventsCounter >= mouseEventsInitialCount)
- && (mouseEventsCounter - mouseEventsInitialCount) <= maxEntropyLevel)
- mouseEntropyGathered = mouseEventsCounter - mouseEventsInitialCount;
- else
- mouseEntropyGathered = maxEntropyLevel;
-
- SendMessage (hEntropyBar, PBM_SETPOS,
- (WPARAM) (mouseEntropyGathered),
- 0);
- }
+ ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered);
if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0)
{
outputDispBuffer[0] = 0;
@@ -11507,4 +11470,41 @@ int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz)
{
return SHStrDupWFn (psz, ppwsz);
}
+
+
+void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy)
+{
+ /* conservative estimate: 1 mouse move event brings 1 bit of entropy
+ * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848
+ */
+ if (*pdwEntropy == 0xFFFFFFFF)
+ {
+ *pdwInitialValue = dwCounter;
+ *pdwEntropy = 0;
+ }
+ else
+ {
+ if ( *pdwEntropy < dwMaxLevel
+ && (dwCounter >= *pdwInitialValue)
+ && (dwCounter - *pdwInitialValue) <= dwMaxLevel)
+ *pdwEntropy = dwCounter - *pdwInitialValue;
+ else
+ *pdwEntropy = dwMaxLevel;
+
+ if (IsOSAtLeast (WIN_VISTA))
+ {
+ int state = PBST_ERROR;
+ if (*pdwEntropy >= (dwMaxLevel/2))
+ state = PBST_NORMAL;
+ else if (*pdwEntropy >= (dwMaxLevel/4))
+ state = PBST_PAUSED;
+
+ SendMessage (hProgress, PBM_SETSTATE, state, 0);
+ }
+
+ SendMessage (hProgress, PBM_SETPOS,
+ (WPARAM) (*pdwEntropy),
+ 0);
+ }
+}
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 553a0cc9..efaf935b 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -497,8 +497,9 @@ HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid);
LSTATUS DeleteRegistryKey (HKEY, LPCTSTR);
HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow);
int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
+void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
#ifdef __cplusplus
}
diff --git a/src/Common/Progress.h b/src/Common/Progress.h
index 27ee659c..9e80a086 100644
--- a/src/Common/Progress.h
+++ b/src/Common/Progress.h
@@ -14,8 +14,17 @@
#ifdef __cplusplus
extern "C" {
#endif
+#ifndef PBM_SETSTATE
+
+#define PBM_SETSTATE (WM_USER+16) // wParam = PBST_[State] (NORMAL, ERROR, PAUSED)
+#define PBST_NORMAL 0x0001
+#define PBST_ERROR 0x0002
+#define PBST_PAUSED 0x0003
+
+#endif
+
void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL bIOThroughput, BOOL bDisplayStatus, BOOL bShowPercent);
BOOL UpdateProgressBar (__int64 byteOffset);
BOOL UpdateProgressBarProc (__int64 byteOffset);
diff --git a/src/ExpandVolume/DlgExpandVolume.cpp b/src/ExpandVolume/DlgExpandVolume.cpp
index 73a38b59..0a24c2c2 100644
--- a/src/ExpandVolume/DlgExpandVolume.cpp
+++ b/src/ExpandVolume/DlgExpandVolume.cpp
@@ -345,29 +345,9 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
DWORD mouseEventsCounter;
RandpeekBytes (hwndDlg, randPool, sizeof (randPool),&mouseEventsCounter);
- /* conservative estimate: 1 mouse move event brings 1 bit of entropy
- * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848
- */
- if (mouseEntropyGathered == 0xFFFFFFFF)
- {
- mouseEventsInitialCount = mouseEventsCounter;
- mouseEntropyGathered = 0;
- }
- else
- {
- if ( mouseEntropyGathered < maxEntropyLevel
- && (mouseEventsCounter >= mouseEventsInitialCount)
- && (mouseEventsCounter - mouseEventsInitialCount) <= maxEntropyLevel)
- mouseEntropyGathered = mouseEventsCounter - mouseEventsInitialCount;
- else
- mouseEntropyGathered = maxEntropyLevel;
-
- SendMessage (hEntropyBar, PBM_SETPOS,
- (WPARAM) (mouseEntropyGathered),
- 0);
- }
+ ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered);
if (showRandPool)
StringCbPrintfW (szRndPool, sizeof(szRndPool), L"%08X%08X%08X%08X",
*((DWORD*) (randPool + 12)), *((DWORD*) (randPool + 8)), *((DWORD*) (randPool + 4)), *((DWORD*) (randPool)));
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index 25be494d..3e228ac0 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
Binary files differ