diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-04-05 22:21:59 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-04-06 00:22:36 +0200 |
commit | 2784652ab880dcea82aa212096b64d39695012fc (patch) | |
tree | b6cc4636a3e47efaeae338dca1fca87a347b82b8 /src/Common/Exception.h | |
parent | a284922ce45ca777dd98b53e846603c63cb44904 (diff) | |
download | VeraCrypt-2784652ab880dcea82aa212096b64d39695012fc.tar.gz VeraCrypt-2784652ab880dcea82aa212096b64d39695012fc.zip |
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.
Diffstat (limited to 'src/Common/Exception.h')
-rw-r--r-- | src/Common/Exception.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Common/Exception.h b/src/Common/Exception.h index e5d4fd4c..0883df14 100644 --- a/src/Common/Exception.h +++ b/src/Common/Exception.h @@ -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) { }
|