mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-01-04 04:38:12 -06:00
Windows vulnerability fix: CryptAcquireContext vulnerability fix. Add checks to random generator to abort in case of error and display a diagnose message to the user.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "Platform/PlatformBase.h"
|
||||
#include "Dlgcode.h"
|
||||
#include <strsafe.h>
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
@@ -62,6 +63,38 @@ namespace VeraCrypt
|
||||
const char *SrcPos;
|
||||
};
|
||||
|
||||
struct RandInitFailed : public Exception
|
||||
{
|
||||
RandInitFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
||||
|
||||
void Show (HWND parent) const
|
||||
{
|
||||
char szErrCode[16];
|
||||
StringCbPrintf (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
|
||||
string msgBody = "The Random Generator initialization failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||
MessageBox (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||
}
|
||||
|
||||
const char *SrcPos;
|
||||
DWORD LastError;
|
||||
};
|
||||
|
||||
struct CryptoApiFailed : public Exception
|
||||
{
|
||||
CryptoApiFailed (const char *srcPos, DWORD dwLastError) : SrcPos (srcPos), LastError (dwLastError) { }
|
||||
|
||||
void Show (HWND parent) const
|
||||
{
|
||||
char szErrCode[16];
|
||||
StringCbPrintf (szErrCode, sizeof(szErrCode), "0x%.8X", LastError);
|
||||
string msgBody = "Windows Crypto API failed.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + string (SrcPos) + "\nLast Error = " + string (szErrCode) + ")";
|
||||
MessageBox (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND);
|
||||
}
|
||||
|
||||
const char *SrcPos;
|
||||
DWORD LastError;
|
||||
};
|
||||
|
||||
struct TimeOut : public Exception
|
||||
{
|
||||
TimeOut (const char *srcPos) { }
|
||||
|
||||
Reference in New Issue
Block a user