mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 11:28:26 -06:00
Linux/MacOSX: Implement TrueCrypt conversion and loading support. Correct many GTK issues linked to multi-threaded origine of events by implementing an automatic mechanism for handling such requests in the main thread.
This commit is contained in:
@@ -23,6 +23,7 @@ namespace VeraCrypt
|
||||
ArgNoHiddenVolumeProtection (false),
|
||||
ArgSize (0),
|
||||
ArgVolumeType (VolumeType::Unknown),
|
||||
ArgTrueCryptMode (false),
|
||||
StartBackgroundTask (false)
|
||||
{
|
||||
parser.SetSwitchChars (L"-");
|
||||
@@ -71,6 +72,7 @@ namespace VeraCrypt
|
||||
parser.AddSwitch (L"", L"quick", _("Enable quick format"));
|
||||
parser.AddOption (L"", L"size", _("Size in bytes"));
|
||||
parser.AddOption (L"", L"slot", _("Volume slot number"));
|
||||
parser.AddOption (L"tc",L"truecrypt", _("Enable TrueCrypt mode. Should be put first to avoid issues."));
|
||||
parser.AddSwitch (L"", L"test", _("Test internal algorithms"));
|
||||
parser.AddSwitch (L"t", L"text", _("Use text user interface"));
|
||||
parser.AddOption (L"", L"token-lib", _("Security token library"));
|
||||
@@ -288,6 +290,8 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
ArgForce = parser.Found (L"force");
|
||||
|
||||
ArgTrueCryptMode = parser.Found (L"truecrypt");
|
||||
|
||||
#if !defined(TC_WINDOWS) && !defined(TC_MACOSX)
|
||||
if (parser.Found (L"fs-options", &str))
|
||||
@@ -401,7 +405,7 @@ namespace VeraCrypt
|
||||
if (wxString (hash->GetName()).IsSameAs (str, false))
|
||||
{
|
||||
bHashFound = true;
|
||||
ArgMountOptions.ProtectionKdf = Pkcs5Kdf::GetAlgorithm (*hash);
|
||||
ArgMountOptions.ProtectionKdf = Pkcs5Kdf::GetAlgorithm (*hash, ArgTrueCryptMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace VeraCrypt
|
||||
shared_ptr <VolumePath> ArgVolumePath;
|
||||
VolumeInfoList ArgVolumes;
|
||||
VolumeType::Enum ArgVolumeType;
|
||||
bool ArgTrueCryptMode;
|
||||
|
||||
bool StartBackgroundTask;
|
||||
UserPreferences Preferences;
|
||||
|
||||
14
src/Main/Forms/ChangePasswordDialog.cpp
Executable file → Normal file
14
src/Main/Forms/ChangePasswordDialog.cpp
Executable file → Normal file
@@ -48,11 +48,11 @@ namespace VeraCrypt
|
||||
throw ParameterIncorrect (SRC_POS);
|
||||
}
|
||||
|
||||
CurrentPasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, false, true, true);
|
||||
CurrentPasswordPanel = new VolumePasswordPanel (this, password, false, keyfiles, false, true, true, false, true, true);
|
||||
CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
|
||||
CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND);
|
||||
|
||||
NewPasswordPanel = new VolumePasswordPanel (this, newPassword, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
|
||||
NewPasswordPanel = new VolumePasswordPanel (this, newPassword, true, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
|
||||
NewPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
|
||||
NewPasswordPanelSizer->Add (NewPasswordPanel, 1, wxALL | wxEXPAND);
|
||||
|
||||
@@ -81,6 +81,14 @@ namespace VeraCrypt
|
||||
|
||||
try
|
||||
{
|
||||
shared_ptr <Pkcs5Kdf> currentKdf = CurrentPasswordPanel->GetPkcs5Kdf();
|
||||
if (currentKdf && CurrentPasswordPanel->GetTrueCryptMode() && (currentKdf->GetName() == L"HMAC-SHA-256"))
|
||||
{
|
||||
Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr <VolumePassword> newPassword;
|
||||
if (DialogMode == Mode::ChangePasswordAndKeyfiles)
|
||||
{
|
||||
@@ -126,7 +134,7 @@ namespace VeraCrypt
|
||||
#endif
|
||||
wxBusyCursor busy;
|
||||
ChangePasswordThreadRoutine routine(Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps,
|
||||
CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetKeyfiles(),
|
||||
CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetTrueCryptMode(),CurrentPasswordPanel->GetKeyfiles(),
|
||||
newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount());
|
||||
WaitDialog dlg(this, LangString["IDT_STATIC_MODAL_WAIT_DLG_INFO"], &routine);
|
||||
dlg.Run();
|
||||
|
||||
5
src/Main/Forms/Forms.cpp
Executable file → Normal file
5
src/Main/Forms/Forms.cpp
Executable file → Normal file
@@ -3209,7 +3209,10 @@ VolumePasswordPanelBase::VolumePasswordPanelBase( wxWindow* parent, wxWindowID i
|
||||
int Pkcs5PrfChoiceNChoices = sizeof( Pkcs5PrfChoiceChoices ) / sizeof( wxString );
|
||||
Pkcs5PrfChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Pkcs5PrfChoiceNChoices, Pkcs5PrfChoiceChoices, 0 );
|
||||
Pkcs5PrfChoice->SetSelection( 0 );
|
||||
GridBagSizer->Add( Pkcs5PrfChoice, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
GridBagSizer->Add( Pkcs5PrfChoice, wxGBPosition( 7, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
TrueCryptModeCheckBox = new wxCheckBox( this, wxID_ANY, _("TrueCrypt Mode"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
GridBagSizer->Add( TrueCryptModeCheckBox, wxGBPosition( 7, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
HeaderWipeCountText = new wxStaticText( this, wxID_ANY, _("Header Wipe:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
HeaderWipeCountText->Wrap( -1 );
|
||||
|
||||
1
src/Main/Forms/Forms.h
Executable file → Normal file
1
src/Main/Forms/Forms.h
Executable file → Normal file
@@ -962,6 +962,7 @@ namespace VeraCrypt
|
||||
wxBoxSizer* Pkcs5PrfSizer;
|
||||
wxStaticText* Pkcs5PrfStaticText;
|
||||
wxChoice* Pkcs5PrfChoice;
|
||||
wxCheckBox* TrueCryptModeCheckBox;
|
||||
wxStaticText* HeaderWipeCountText;
|
||||
wxChoice* HeaderWipeCount;
|
||||
wxBoxSizer* PasswordPlaceholderSizer;
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace VeraCrypt
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_UPDATE_VOLUME_LIST)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_PREF_UPDATED)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_OPEN_VOLUME_REQUEST)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_SHOW_WARNING)
|
||||
|
||||
MainFrame::MainFrame (wxWindow* parent) : MainFrameBase (parent),
|
||||
ListItemRightClickEventPending (false),
|
||||
@@ -1495,6 +1496,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
VolumeInfoList protectionTriggeredVolumes;
|
||||
SlotListCtrl->SetColumnWidth(0, wxLIST_AUTOSIZE);
|
||||
|
||||
// Update list
|
||||
long prevItemIndex = -1;
|
||||
@@ -1516,7 +1518,7 @@ namespace VeraCrypt
|
||||
#endif
|
||||
fields[ColumnPath] = volume->Path;
|
||||
fields[ColumnSize] = Gui->SizeToString (volume->Size);
|
||||
fields[ColumnType] = Gui->VolumeTypeToString (volume->Type, volume->Protection);
|
||||
fields[ColumnType] = Gui->VolumeTypeToString (volume->Type, volume->TrueCryptMode, volume->Protection);
|
||||
|
||||
if (volume->HiddenVolumeProtectionTriggered)
|
||||
{
|
||||
|
||||
12
src/Main/Forms/MountOptionsDialog.cpp
Executable file → Normal file
12
src/Main/Forms/MountOptionsDialog.cpp
Executable file → Normal file
@@ -30,7 +30,7 @@ namespace VeraCrypt
|
||||
if (disableMountOptions)
|
||||
OptionsButton->Show (false);
|
||||
|
||||
PasswordPanel = new VolumePasswordPanel (this, options.Password, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
|
||||
PasswordPanel = new VolumePasswordPanel (this, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
|
||||
PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));
|
||||
|
||||
PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
|
||||
@@ -61,7 +61,7 @@ namespace VeraCrypt
|
||||
OptionsButton->SetLabel (OptionsButtonLabel + L" >");
|
||||
OptionsPanel->Show (false);
|
||||
|
||||
ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:"));
|
||||
ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, true, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:"));
|
||||
ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND);
|
||||
|
||||
UpdateDialog();
|
||||
@@ -86,6 +86,7 @@ namespace VeraCrypt
|
||||
|
||||
Options.Password = PasswordPanel->GetPassword();
|
||||
Options.Kdf = PasswordPanel->GetPkcs5Kdf();
|
||||
Options.TrueCryptMode = PasswordPanel->GetTrueCryptMode();
|
||||
Options.Keyfiles = PasswordPanel->GetKeyfiles();
|
||||
|
||||
if (ReadOnlyCheckBox->IsChecked())
|
||||
@@ -119,6 +120,13 @@ namespace VeraCrypt
|
||||
{
|
||||
Gui->ShowWarning (LangString ["UNSUPPORTED_CHARS_IN_PWD_RECOM"]);
|
||||
}
|
||||
|
||||
if (Options.TrueCryptMode && Options.Kdf && (Options.Kdf->GetName() == L"HMAC-SHA-256"))
|
||||
{
|
||||
Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
EndModal (wxID_OK);
|
||||
}
|
||||
|
||||
93
src/Main/Forms/TrueCrypt.fbp
Executable file → Normal file
93
src/Main/Forms/TrueCrypt.fbp
Executable file → Normal file
@@ -26014,7 +26014,7 @@
|
||||
</object>
|
||||
<object class="gbsizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="colspan">2</property>
|
||||
<property name="colspan">1</property>
|
||||
<property name="column">1</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="row">7</property>
|
||||
@@ -26104,6 +26104,97 @@
|
||||
</object>
|
||||
</object>
|
||||
<object class="gbsizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="colspan">1</property>
|
||||
<property name="column">2</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
|
||||
<property name="row">7</property>
|
||||
<property name="rowspan">1</property>
|
||||
<object class="wxCheckBox" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">TrueCrypt Mode</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">TrueCryptModeCheckBox</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCheckBox"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="gbsizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="colspan">1</property>
|
||||
<property name="column">0</property>
|
||||
|
||||
@@ -863,7 +863,7 @@ namespace VeraCrypt
|
||||
options->Quick = QuickFormatEnabled;
|
||||
options->Size = VolumeSize;
|
||||
options->Type = OuterVolume ? VolumeType::Normal : SelectedVolumeType;
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*SelectedHash);
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*SelectedHash, false);
|
||||
|
||||
Creator.reset (new VolumeCreator);
|
||||
VolumeCreatorThreadRoutine routine(options, Creator);
|
||||
@@ -941,7 +941,7 @@ namespace VeraCrypt
|
||||
});
|
||||
#endif
|
||||
|
||||
shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Kdf, Keyfiles, VolumeProtection::ReadOnly);
|
||||
shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Kdf, false, Keyfiles, VolumeProtection::ReadOnly);
|
||||
MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume);
|
||||
|
||||
// Add a reserve (in case the user mounts the outer volume and creates new files
|
||||
|
||||
12
src/Main/Forms/VolumePasswordPanel.cpp
Executable file → Normal file
12
src/Main/Forms/VolumePasswordPanel.cpp
Executable file → Normal file
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel)
|
||||
VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel)
|
||||
: VolumePasswordPanelBase (parent), Keyfiles (new KeyfileList)
|
||||
{
|
||||
if (keyfiles)
|
||||
@@ -63,6 +63,7 @@ namespace VeraCrypt
|
||||
|
||||
Pkcs5PrfStaticText->Show (enablePkcs5Prf);
|
||||
Pkcs5PrfChoice->Show (enablePkcs5Prf);
|
||||
TrueCryptModeCheckBox->Show (!disableTruecryptMode);
|
||||
HeaderWipeCountText->Show (enablePkcs5Prf && !isMountPassword);
|
||||
HeaderWipeCount->Show (enablePkcs5Prf && !isMountPassword);
|
||||
|
||||
@@ -74,7 +75,7 @@ namespace VeraCrypt
|
||||
Pkcs5PrfChoice->Delete (0);
|
||||
Pkcs5PrfChoice->Append (LangString["AUTODETECTION"]);
|
||||
}
|
||||
foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms())
|
||||
foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms(false))
|
||||
{
|
||||
if (!kdf.IsDeprecated() || isMountPassword)
|
||||
Pkcs5PrfChoice->Append (kdf.GetName());
|
||||
@@ -190,7 +191,7 @@ namespace VeraCrypt
|
||||
{
|
||||
try
|
||||
{
|
||||
return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()));
|
||||
return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()), GetTrueCryptMode());
|
||||
}
|
||||
catch (ParameterIncorrect&)
|
||||
{
|
||||
@@ -198,6 +199,11 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
bool VolumePasswordPanel::GetTrueCryptMode () const
|
||||
{
|
||||
return TrueCryptModeCheckBox->GetValue ();
|
||||
}
|
||||
|
||||
int VolumePasswordPanel::GetHeaderWipeCount () const
|
||||
{
|
||||
try
|
||||
|
||||
3
src/Main/Forms/VolumePasswordPanel.h
Executable file → Normal file
3
src/Main/Forms/VolumePasswordPanel.h
Executable file → Normal file
@@ -18,13 +18,14 @@ namespace VeraCrypt
|
||||
class VolumePasswordPanel : public VolumePasswordPanelBase
|
||||
{
|
||||
public:
|
||||
VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, bool isMountPassword = false, const wxString &passwordLabel = wxString());
|
||||
VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, bool isMountPassword = false, const wxString &passwordLabel = wxString());
|
||||
virtual ~VolumePasswordPanel ();
|
||||
|
||||
void AddKeyfile (shared_ptr <Keyfile> keyfile);
|
||||
shared_ptr <KeyfileList> GetKeyfiles () const { return UseKeyfilesCheckBox->IsChecked() ? Keyfiles : shared_ptr <KeyfileList> (); }
|
||||
shared_ptr <VolumePassword> GetPassword () const;
|
||||
shared_ptr <Pkcs5Kdf> GetPkcs5Kdf () const;
|
||||
bool GetTrueCryptMode () const;
|
||||
int GetHeaderWipeCount () const;
|
||||
void SetCacheCheckBoxValidator (const wxGenericValidator &validator) { CacheCheckBox->SetValidator (validator); }
|
||||
void SetFocusToPasswordTextCtrl () { PasswordTextCtrl->SetSelection (-1, -1); PasswordTextCtrl->SetFocus(); }
|
||||
|
||||
2
src/Main/Forms/VolumePasswordWizardPage.cpp
Executable file → Normal file
2
src/Main/Forms/VolumePasswordWizardPage.cpp
Executable file → Normal file
@@ -15,7 +15,7 @@ namespace VeraCrypt
|
||||
VolumePasswordWizardPage::VolumePasswordWizardPage (wxPanel* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableConfirmation)
|
||||
: VolumePasswordWizardPageBase (parent), ConfirmationMode (enableConfirmation)
|
||||
{
|
||||
PasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, enableConfirmation, !enableConfirmation, !enableConfirmation);
|
||||
PasswordPanel = new VolumePasswordPanel (this, password, true, keyfiles, false, true, true, enableConfirmation, !enableConfirmation, !enableConfirmation);
|
||||
PasswordPanel->UpdateEvent.Connect (EventConnector <VolumePasswordWizardPage> (this, &VolumePasswordWizardPage::OnPasswordPanelUpdate));
|
||||
|
||||
PasswordPanelSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace VeraCrypt
|
||||
AppendToList ("VIRTUAL_DEVICE", wstring (volumeInfo.VirtualDevice));
|
||||
#endif
|
||||
AppendToList ("SIZE", Gui->SizeToString (volumeInfo.Size));
|
||||
AppendToList ("TYPE", Gui->VolumeTypeToString (volumeInfo.Type, volumeInfo.Protection));
|
||||
AppendToList ("TYPE", Gui->VolumeTypeToString (volumeInfo.Type, volumeInfo.TrueCryptMode, volumeInfo.Protection));
|
||||
AppendToList ("READ_ONLY", LangString [volumeInfo.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"]);
|
||||
|
||||
wxString protection;
|
||||
|
||||
11
src/Main/Forms/WaitDialog.cpp
Executable file → Normal file
11
src/Main/Forms/WaitDialog.cpp
Executable file → Normal file
@@ -15,11 +15,12 @@
|
||||
namespace VeraCrypt
|
||||
{
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_PIN)
|
||||
DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_SHOW_MSG)
|
||||
|
||||
wxThread::ExitCode WaitThread::Entry()
|
||||
{
|
||||
wxCommandEvent finishEvent( wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED,0);
|
||||
|
||||
{
|
||||
m_pRoutine->Execute();
|
||||
wxQueueEvent (m_pHandler, new wxCommandEvent( wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED,0));
|
||||
return (wxThread::ExitCode)0; // success
|
||||
@@ -88,7 +89,9 @@ namespace VeraCrypt
|
||||
VC_CONVERT_EXCEPTION (InvalidSecurityTokenKeyfilePath);
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenLibraryNotInitialized);
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenKeyfileAlreadyExists);
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenKeyfileNotFound);
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenKeyfileNotFound);
|
||||
VC_CONVERT_EXCEPTION (UnsupportedAlgoInTrueCryptMode);
|
||||
VC_CONVERT_EXCEPTION (UnsupportedTrueCryptFormat);
|
||||
throw *ex;
|
||||
}
|
||||
}
|
||||
|
||||
122
src/Main/Forms/WaitDialog.h
Executable file → Normal file
122
src/Main/Forms/WaitDialog.h
Executable file → Normal file
@@ -11,11 +11,16 @@
|
||||
|
||||
#include "Forms.h"
|
||||
#include "Main/Main.h"
|
||||
#include "Main/Application.h"
|
||||
#include <wx/msgqueue.h>
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED, -1);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD, -1);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_PIN, -1);
|
||||
DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_SHOW_MSG, -1);
|
||||
|
||||
class WaitDialog;
|
||||
|
||||
@@ -50,6 +55,10 @@ namespace VeraCrypt
|
||||
GetSizer()->Fit( this );
|
||||
Centre( wxBOTH );
|
||||
Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED, wxCommandEventHandler( WaitDialog::OnThreadCompletion ) );
|
||||
Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD, wxCommandEventHandler( WaitDialog::OnAdminPasswordRequest ) );
|
||||
Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_PIN, wxCommandEventHandler( WaitDialog::OnPinRequest ) );
|
||||
Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_SHOW_MSG, wxCommandEventHandler( WaitDialog::OnShowMsg ) );
|
||||
|
||||
Connect( wxEVT_TIMER, wxTimerEventHandler( WaitDialog::OnProgressTimer ), NULL, this );
|
||||
m_thread = new WaitThread(this, pRoutine);
|
||||
}
|
||||
@@ -58,6 +67,9 @@ namespace VeraCrypt
|
||||
{
|
||||
Disconnect( wxEVT_TIMER, wxTimerEventHandler( WaitDialog::OnProgressTimer ));
|
||||
Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED, wxCommandEventHandler( WaitDialog::OnThreadCompletion ) );
|
||||
Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD, wxCommandEventHandler( WaitDialog::OnAdminPasswordRequest ) );
|
||||
Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_PIN, wxCommandEventHandler( WaitDialog::OnPinRequest ) );
|
||||
Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_SHOW_MSG, wxCommandEventHandler( WaitDialog::OnShowMsg ) );
|
||||
}
|
||||
|
||||
virtual void OnWaitDialogInit( wxInitDialogEvent& event )
|
||||
@@ -65,12 +77,119 @@ namespace VeraCrypt
|
||||
m_thread->Run();
|
||||
m_timer.Start(100);
|
||||
}
|
||||
|
||||
int GetCharWidth (wxWindow *window) const
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
window->GetTextExtent (L"a", &width, &height);
|
||||
|
||||
if (width < 1)
|
||||
return 7;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
class ShowMessageParam
|
||||
{
|
||||
public:
|
||||
wxString m_message;
|
||||
wxString m_caption;
|
||||
long m_style;
|
||||
bool m_topMost;
|
||||
ShowMessageParam(const wxString &message, const wxString &caption,long style, bool topMost)
|
||||
: m_message(message), m_caption(caption), m_style(style), m_topMost(topMost)
|
||||
{}
|
||||
};
|
||||
|
||||
int RequestShowMessage (const wxString &message, const wxString &caption,long style, bool topMost)
|
||||
{
|
||||
long lResult = -1;
|
||||
if (m_queue.IsOk())
|
||||
{
|
||||
wxString sResult;
|
||||
ShowMessageParam* pParam = new ShowMessageParam(message, caption, style, topMost);
|
||||
wxCommandEvent* pEvent = new wxCommandEvent( wxEVT_COMMAND_WAITDIALOG_SHOW_MSG,0);
|
||||
pEvent->SetClientData (pParam);
|
||||
wxQueueEvent (this, pEvent);
|
||||
m_queue.Receive (sResult);
|
||||
sResult.ToLong(&lResult);
|
||||
}
|
||||
return (int) lResult;
|
||||
}
|
||||
|
||||
void RequestAdminPassword (wxString& adminPassword)
|
||||
{
|
||||
if (m_queue.IsOk())
|
||||
{
|
||||
wxQueueEvent (this, new wxCommandEvent( wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD,0));
|
||||
if (wxMSGQUEUE_NO_ERROR != m_queue.Receive (adminPassword))
|
||||
adminPassword = wxT("");
|
||||
}
|
||||
else
|
||||
adminPassword = wxT("");
|
||||
}
|
||||
|
||||
void RequestPin (wxString& pin)
|
||||
{
|
||||
if (m_queue.IsOk())
|
||||
{
|
||||
wxCommandEvent* pEvent = new wxCommandEvent( wxEVT_COMMAND_WAITDIALOG_PIN,0);
|
||||
pEvent->SetString (pin);
|
||||
wxQueueEvent (this, pEvent);
|
||||
if (wxMSGQUEUE_NO_ERROR != m_queue.Receive (pin))
|
||||
pin = wxT("");
|
||||
}
|
||||
else
|
||||
pin = wxT("");
|
||||
}
|
||||
|
||||
// virtual void OnWaitDialogClose( wxCloseEvent& event ) { }
|
||||
void OnThreadCompletion(wxCommandEvent &)
|
||||
{
|
||||
m_queue.Clear();
|
||||
EndModal(0);
|
||||
}
|
||||
|
||||
void OnAdminPasswordRequest(wxCommandEvent &)
|
||||
{
|
||||
|
||||
wxPasswordEntryDialog dialog (this, _("Enter your user password or administrator password:"), _("Administrator privileges required"));
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
m_queue.Post(wxT(""));
|
||||
else
|
||||
m_queue.Post(dialog.GetValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OnPinRequest(wxCommandEvent &e)
|
||||
{
|
||||
|
||||
wxPasswordEntryDialog dialog (this, wxString::Format (LangString["ENTER_TOKEN_PASSWORD"], e.GetString()), LangString["IDD_TOKEN_PASSWORD"]);
|
||||
dialog.SetSize (wxSize (GetCharWidth (&dialog) * 50, -1));
|
||||
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
m_queue.Post(wxT(""));
|
||||
else
|
||||
m_queue.Post(dialog.GetValue());
|
||||
}
|
||||
|
||||
void OnShowMsg(wxCommandEvent &e)
|
||||
{
|
||||
ShowMessageParam* pParam = (ShowMessageParam*) e.GetClientData();
|
||||
if (pParam->m_topMost)
|
||||
{
|
||||
if (!IsActive())
|
||||
RequestUserAttention (wxUSER_ATTENTION_ERROR);
|
||||
|
||||
pParam->m_style |= wxSTAY_ON_TOP;
|
||||
}
|
||||
|
||||
int iResult = wxMessageBox (pParam->m_message, pParam->m_caption, pParam->m_style, this);
|
||||
delete pParam;
|
||||
m_queue.Post(wxString::Format(wxT("%d"), iResult));
|
||||
}
|
||||
|
||||
void OnProgressTimer(wxTimerEvent& event)
|
||||
{
|
||||
@@ -83,7 +202,8 @@ namespace VeraCrypt
|
||||
|
||||
protected:
|
||||
WaitThread* m_thread;
|
||||
wxTimer m_timer;
|
||||
wxTimer m_timer;
|
||||
wxMessageQueue<wxString> m_queue;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
78
src/Main/GraphicUserInterface.cpp
Executable file → Normal file
78
src/Main/GraphicUserInterface.cpp
Executable file → Normal file
@@ -30,14 +30,14 @@
|
||||
#include "Forms/MountOptionsDialog.h"
|
||||
#include "Forms/RandomPoolEnrichmentDialog.h"
|
||||
#include "Forms/SecurityTokenKeyfilesDialog.h"
|
||||
#include "Forms/WaitDialog.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
GraphicUserInterface::GraphicUserInterface () :
|
||||
ActiveFrame (nullptr),
|
||||
BackgroundMode (false),
|
||||
mMainFrame (nullptr)
|
||||
mMainFrame (nullptr),
|
||||
mWaitDialog (nullptr)
|
||||
{
|
||||
#ifdef TC_UNIX
|
||||
signal (SIGHUP, OnSignal);
|
||||
@@ -179,6 +179,7 @@ namespace VeraCrypt
|
||||
options->PreserveTimestamps,
|
||||
options->Password,
|
||||
options->Kdf,
|
||||
false,
|
||||
options->Keyfiles,
|
||||
options->Protection,
|
||||
options->ProtectionPassword,
|
||||
@@ -409,12 +410,22 @@ namespace VeraCrypt
|
||||
{
|
||||
virtual void operator() (string &passwordStr)
|
||||
{
|
||||
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), _("Enter your user password or administrator password:"), _("Administrator privileges required"));
|
||||
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
throw UserAbort (SRC_POS);
|
||||
|
||||
wstring wPassword (dialog.GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased
|
||||
wxString sValue;
|
||||
if (Gui->GetWaitDialog())
|
||||
{
|
||||
Gui->GetWaitDialog()->RequestAdminPassword(sValue);
|
||||
if (sValue.IsEmpty())
|
||||
throw UserAbort (SRC_POS);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), _("Enter your user password or administrator password:"), _("Administrator privileges required"));
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
throw UserAbort (SRC_POS);
|
||||
sValue = dialog.GetValue();
|
||||
}
|
||||
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
|
||||
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });
|
||||
|
||||
StringConverter::ToSingle (wPassword, passwordStr);
|
||||
@@ -525,13 +536,25 @@ namespace VeraCrypt
|
||||
if (Gui->GetPreferences().NonInteractive)
|
||||
throw MissingArgument (SRC_POS);
|
||||
|
||||
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), wxString::Format (LangString["ENTER_TOKEN_PASSWORD"], StringConverter::ToWide (passwordStr).c_str()), LangString["IDD_TOKEN_PASSWORD"]);
|
||||
dialog.SetSize (wxSize (Gui->GetCharWidth (&dialog) * 50, -1));
|
||||
wxString sValue;
|
||||
if (Gui->GetWaitDialog())
|
||||
{
|
||||
sValue = StringConverter::ToWide (passwordStr).c_str();
|
||||
Gui->GetWaitDialog()->RequestPin (sValue);
|
||||
if (sValue.IsEmpty ())
|
||||
throw UserAbort (SRC_POS);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), wxString::Format (LangString["ENTER_TOKEN_PASSWORD"], StringConverter::ToWide (passwordStr).c_str()), LangString["IDD_TOKEN_PASSWORD"]);
|
||||
dialog.SetSize (wxSize (Gui->GetCharWidth (&dialog) * 50, -1));
|
||||
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
throw UserAbort (SRC_POS);
|
||||
if (dialog.ShowModal() != wxID_OK)
|
||||
throw UserAbort (SRC_POS);
|
||||
sValue = dialog.GetValue();
|
||||
}
|
||||
|
||||
wstring wPassword (dialog.GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased
|
||||
wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased
|
||||
finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); });
|
||||
|
||||
StringConverter::ToSingle (wPassword, passwordStr);
|
||||
@@ -1273,6 +1296,7 @@ namespace VeraCrypt
|
||||
options.PreserveTimestamps,
|
||||
options.Password,
|
||||
options.Kdf,
|
||||
options.TrueCryptMode,
|
||||
options.Keyfiles,
|
||||
options.Protection,
|
||||
options.ProtectionPassword,
|
||||
@@ -1392,11 +1416,11 @@ namespace VeraCrypt
|
||||
|
||||
// Decrypt header
|
||||
shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password);
|
||||
Pkcs5KdfList keyDerivationFunctions = layout->GetSupportedKeyDerivationFunctions();
|
||||
Pkcs5KdfList keyDerivationFunctions = layout->GetSupportedKeyDerivationFunctions(options.TrueCryptMode);
|
||||
EncryptionAlgorithmList encryptionAlgorithms = layout->GetSupportedEncryptionAlgorithms();
|
||||
EncryptionModeList encryptionModes = layout->GetSupportedEncryptionModes();
|
||||
|
||||
DecryptThreadRoutine decryptRoutine(layout->GetHeader(), headerBuffer, *passwordKey, options.Kdf, keyDerivationFunctions, encryptionAlgorithms, encryptionModes);
|
||||
DecryptThreadRoutine decryptRoutine(layout->GetHeader(), headerBuffer, *passwordKey, options.Kdf, options.TrueCryptMode, keyDerivationFunctions, encryptionAlgorithms, encryptionModes);
|
||||
WaitDialog decryptDlg(parent, LangString["IDT_STATIC_MODAL_WAIT_DLG_INFO"], &decryptRoutine);
|
||||
decryptDlg.Run();
|
||||
|
||||
@@ -1713,15 +1737,22 @@ namespace VeraCrypt
|
||||
caption.clear();
|
||||
}
|
||||
#endif
|
||||
if (topMost)
|
||||
if (mWaitDialog)
|
||||
{
|
||||
if (!IsActive())
|
||||
mMainFrame->RequestUserAttention (wxUSER_ATTENTION_ERROR);
|
||||
|
||||
style |= wxSTAY_ON_TOP;
|
||||
return mWaitDialog->RequestShowMessage(subMessage, caption, style, topMost);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (topMost)
|
||||
{
|
||||
if (!IsActive())
|
||||
mMainFrame->RequestUserAttention (wxUSER_ATTENTION_ERROR);
|
||||
|
||||
return wxMessageBox (subMessage, caption, style, GetActiveWindow());
|
||||
style |= wxSTAY_ON_TOP;
|
||||
}
|
||||
|
||||
return wxMessageBox (subMessage, caption, style, GetActiveWindow());
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicUserInterface::ShowWarningTopMost (const wxString &message) const
|
||||
@@ -1758,6 +1789,8 @@ namespace VeraCrypt
|
||||
{
|
||||
item.SetText (field);
|
||||
listCtrl->SetItem (item);
|
||||
if (item.GetColumn() == 3 || item.GetColumn() == 4)
|
||||
listCtrl->SetColumnWidth(item.GetColumn(), wxLIST_AUTOSIZE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -1794,8 +1827,11 @@ namespace VeraCrypt
|
||||
{
|
||||
MountThreadRoutine routine(options);
|
||||
WaitDialog dlg(GetTopWindow(), LangString["IDT_STATIC_MODAL_WAIT_DLG_INFO"], &routine);
|
||||
|
||||
mWaitDialog = &dlg;
|
||||
finally_do_arg (WaitDialog**, &mWaitDialog, { *finally_arg = nullptr; });
|
||||
|
||||
dlg.Run();
|
||||
|
||||
return routine.m_pVolume;
|
||||
}
|
||||
|
||||
|
||||
8
src/Main/GraphicUserInterface.h
Executable file → Normal file
8
src/Main/GraphicUserInterface.h
Executable file → Normal file
@@ -13,6 +13,7 @@
|
||||
#include <utility>
|
||||
#include "Main.h"
|
||||
#include "UserInterface.h"
|
||||
#include "Forms/WaitDialog.h"
|
||||
|
||||
namespace VeraCrypt
|
||||
{
|
||||
@@ -29,7 +30,7 @@ namespace VeraCrypt
|
||||
virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
|
||||
virtual void BeginBusyState () const { wxBeginBusyCursor(); }
|
||||
virtual void BeginInteractiveBusyState (wxWindow *window);
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const { ThrowTextModeRequired(); }
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), bool truecryptMode = false, shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const { ThrowTextModeRequired(); }
|
||||
wxHyperlinkCtrl *CreateHyperlink (wxWindow *parent, const wxString &linkUrl, const wxString &linkText) const;
|
||||
virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const;
|
||||
virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const { ThrowTextModeRequired(); }
|
||||
@@ -84,12 +85,13 @@ namespace VeraCrypt
|
||||
virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); }
|
||||
virtual void ShowInfoTopMost (const wxString &message) const;
|
||||
virtual void ShowWarningTopMost (char *langStringId) const { ShowWarningTopMost (LangString[langStringId]); }
|
||||
virtual void ShowWarningTopMost (const wxString &message) const;
|
||||
virtual void ShowWarningTopMost (const wxString &message) const;
|
||||
virtual bool UpdateListCtrlItem (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields) const;
|
||||
virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr <Hash> hash = shared_ptr <Hash>()) const;
|
||||
virtual void Yield () const;
|
||||
virtual WaitThreadUI* GetWaitThreadUI(WaitThreadRoutine *pRoutine) const;
|
||||
virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const;
|
||||
WaitDialog* GetWaitDialog () { return mWaitDialog; }
|
||||
|
||||
#ifdef TC_MACOSX
|
||||
virtual void MacOpenFile (const wxString &fileName);
|
||||
@@ -125,6 +127,8 @@ namespace VeraCrypt
|
||||
wxFrame *mMainFrame;
|
||||
auto_ptr <wxSingleInstanceChecker> SingleInstanceChecker;
|
||||
|
||||
mutable WaitDialog* mWaitDialog;
|
||||
|
||||
private:
|
||||
GraphicUserInterface (const GraphicUserInterface &);
|
||||
GraphicUserInterface &operator= (const GraphicUserInterface &);
|
||||
|
||||
21
src/Main/TextUserInterface.cpp
Executable file → Normal file
21
src/Main/TextUserInterface.cpp
Executable file → Normal file
@@ -248,7 +248,7 @@ namespace VeraCrypt
|
||||
shared_ptr <Pkcs5Kdf> kdf;
|
||||
if (CmdLine->ArgHash)
|
||||
{
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash);
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, false);
|
||||
}
|
||||
|
||||
shared_ptr <Volume> normalVolume;
|
||||
@@ -281,6 +281,7 @@ namespace VeraCrypt
|
||||
options->PreserveTimestamps,
|
||||
options->Password,
|
||||
kdf,
|
||||
false,
|
||||
options->Keyfiles,
|
||||
options->Protection,
|
||||
options->ProtectionPassword,
|
||||
@@ -367,7 +368,7 @@ namespace VeraCrypt
|
||||
ShowInfo ("VOL_HEADER_BACKED_UP");
|
||||
}
|
||||
|
||||
void TextUserInterface::ChangePassword (shared_ptr <VolumePath> volumePath, shared_ptr <VolumePassword> password, shared_ptr <Hash> currentHash, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Hash> newHash) const
|
||||
void TextUserInterface::ChangePassword (shared_ptr <VolumePath> volumePath, shared_ptr <VolumePassword> password, shared_ptr <Hash> currentHash, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Hash> newHash) const
|
||||
{
|
||||
shared_ptr <Volume> volume;
|
||||
|
||||
@@ -389,7 +390,7 @@ namespace VeraCrypt
|
||||
shared_ptr<Pkcs5Kdf> kdf;
|
||||
if (currentHash)
|
||||
{
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*currentHash);
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*currentHash, truecryptMode);
|
||||
}
|
||||
|
||||
while (true)
|
||||
@@ -420,7 +421,7 @@ namespace VeraCrypt
|
||||
try
|
||||
{
|
||||
keyfiles.reset (new KeyfileList);
|
||||
volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, keyfiles);
|
||||
volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, truecryptMode, keyfiles);
|
||||
}
|
||||
catch (PasswordException&)
|
||||
{
|
||||
@@ -430,7 +431,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
if (!volume.get())
|
||||
volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, keyfiles);
|
||||
volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, truecryptMode, keyfiles);
|
||||
}
|
||||
catch (PasswordException &e)
|
||||
{
|
||||
@@ -464,7 +465,7 @@ namespace VeraCrypt
|
||||
UserEnrichRandomPool();
|
||||
|
||||
Core->ChangePassword (volume, newPassword, newKeyfiles,
|
||||
newHash ? Pkcs5Kdf::GetAlgorithm (*newHash) : shared_ptr <Pkcs5Kdf>());
|
||||
newHash ? Pkcs5Kdf::GetAlgorithm (*newHash, false) : shared_ptr <Pkcs5Kdf>());
|
||||
|
||||
ShowInfo ("PASSWORD_CHANGED");
|
||||
}
|
||||
@@ -692,7 +693,7 @@ namespace VeraCrypt
|
||||
|
||||
shared_ptr <Hash> selectedHash = hashes[AskSelection (hashes.size(), 1) - 1];
|
||||
RandomNumberGenerator::SetHash (selectedHash);
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*selectedHash);
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*selectedHash, false);
|
||||
|
||||
}
|
||||
|
||||
@@ -1298,11 +1299,10 @@ namespace VeraCrypt
|
||||
|
||||
// Ask whether to restore internal or external backup
|
||||
bool restoreInternalBackup;
|
||||
|
||||
shared_ptr <Pkcs5Kdf> kdf;
|
||||
if (CmdLine->ArgHash)
|
||||
{
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash);
|
||||
kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, false);
|
||||
}
|
||||
|
||||
ShowInfo (LangString["HEADER_RESTORE_EXTERNAL_INTERNAL"]);
|
||||
@@ -1346,6 +1346,7 @@ namespace VeraCrypt
|
||||
options.PreserveTimestamps,
|
||||
options.Password,
|
||||
kdf,
|
||||
false,
|
||||
options.Keyfiles,
|
||||
options.Protection,
|
||||
options.ProtectionPassword,
|
||||
@@ -1454,7 +1455,7 @@ namespace VeraCrypt
|
||||
|
||||
// Decrypt header
|
||||
shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password);
|
||||
if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, kdf, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes()))
|
||||
if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, kdf, false, layout->GetSupportedKeyDerivationFunctions(false), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes()))
|
||||
{
|
||||
decryptedLayout = layout;
|
||||
break;
|
||||
|
||||
2
src/Main/TextUserInterface.h
Executable file → Normal file
2
src/Main/TextUserInterface.h
Executable file → Normal file
@@ -30,7 +30,7 @@ namespace VeraCrypt
|
||||
virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const;
|
||||
virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
|
||||
virtual void BeginBusyState () const { }
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const;
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), bool truecryptMode = false, shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const;
|
||||
virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const;
|
||||
virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const;
|
||||
virtual void DeleteSecurityTokenKeyfiles () const;
|
||||
|
||||
35
src/Main/UserInterface.cpp
Executable file → Normal file
35
src/Main/UserInterface.cpp
Executable file → Normal file
@@ -249,7 +249,7 @@ namespace VeraCrypt
|
||||
#endif
|
||||
prop << LangString["MOUNT_POINT"] << L": " << wstring (volume.MountPoint) << L'\n';
|
||||
prop << LangString["SIZE"] << L": " << SizeToString (volume.Size) << L'\n';
|
||||
prop << LangString["TYPE"] << L": " << VolumeTypeToString (volume.Type, volume.Protection) << L'\n';
|
||||
prop << LangString["TYPE"] << L": " << VolumeTypeToString (volume.Type, volume.TrueCryptMode, volume.Protection) << L'\n';
|
||||
|
||||
prop << LangString["READ_ONLY"] << L": " << LangString [volume.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"] << L'\n';
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace VeraCrypt
|
||||
ShowString (prop);
|
||||
}
|
||||
|
||||
wxString UserInterface::ExceptionToMessage (const exception &ex) const
|
||||
wxString UserInterface::ExceptionToMessage (const exception &ex)
|
||||
{
|
||||
wxString message;
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace VeraCrypt
|
||||
return StringConverter::ToWide (typeName) + L" at " + StringConverter::ToWide (ex.what());
|
||||
}
|
||||
|
||||
wxString UserInterface::ExceptionToString (const Exception &ex) const
|
||||
wxString UserInterface::ExceptionToString (const Exception &ex)
|
||||
{
|
||||
// Error messages
|
||||
const ErrorMessage *errMsgEx = dynamic_cast <const ErrorMessage *> (&ex);
|
||||
@@ -436,7 +436,7 @@ namespace VeraCrypt
|
||||
return ExceptionTypeToString (typeid (ex));
|
||||
}
|
||||
|
||||
wxString UserInterface::ExceptionTypeToString (const std::type_info &ex) const
|
||||
wxString UserInterface::ExceptionTypeToString (const std::type_info &ex)
|
||||
{
|
||||
#define EX2MSG(exception, message) do { if (ex == typeid (exception)) return (message); } while (false)
|
||||
EX2MSG (DriveLetterUnavailable, LangString["DRIVE_LETTER_UNAVAILABLE"]);
|
||||
@@ -483,6 +483,8 @@ namespace VeraCrypt
|
||||
EX2MSG (VolumeEncryptionNotCompleted, LangString["ERR_ENCRYPTION_NOT_COMPLETED"]);
|
||||
EX2MSG (VolumeHostInUse, _("The host file/device is already in use."));
|
||||
EX2MSG (VolumeSlotUnavailable, _("Volume slot unavailable."));
|
||||
EX2MSG (UnsupportedAlgoInTrueCryptMode, LangString["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
|
||||
EX2MSG (UnsupportedTrueCryptFormat, LangString["UNSUPPORTED_TRUECRYPT_FORMAT"]);
|
||||
|
||||
#ifdef TC_MACOSX
|
||||
EX2MSG (HigherFuseVersionRequired, _("VeraCrypt requires OSXFUSE 2.3 or later with MacFUSE compatibility layer installer.\nPlease ensure that you have selected this compatibility layer during OSXFUSE installation."));
|
||||
@@ -885,9 +887,10 @@ namespace VeraCrypt
|
||||
cmdLine.ArgMountOptions.Password = cmdLine.ArgPassword;
|
||||
cmdLine.ArgMountOptions.Keyfiles = cmdLine.ArgKeyfiles;
|
||||
cmdLine.ArgMountOptions.SharedAccessAllowed = cmdLine.ArgForce;
|
||||
cmdLine.ArgMountOptions.TrueCryptMode = cmdLine.ArgTrueCryptMode;
|
||||
if (cmdLine.ArgHash)
|
||||
{
|
||||
cmdLine.ArgMountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*cmdLine.ArgHash);
|
||||
cmdLine.ArgMountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*cmdLine.ArgHash, cmdLine.ArgTrueCryptMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -972,7 +975,7 @@ namespace VeraCrypt
|
||||
return true;
|
||||
|
||||
case CommandId::ChangePassword:
|
||||
ChangePassword (cmdLine.ArgVolumePath, cmdLine.ArgPassword, cmdLine.ArgCurrentHash, cmdLine.ArgKeyfiles, cmdLine.ArgNewPassword, cmdLine.ArgNewKeyfiles, cmdLine.ArgHash);
|
||||
ChangePassword (cmdLine.ArgVolumePath, cmdLine.ArgPassword, cmdLine.ArgCurrentHash, cmdLine.ArgTrueCryptMode, cmdLine.ArgKeyfiles, cmdLine.ArgNewPassword, cmdLine.ArgNewKeyfiles, cmdLine.ArgHash);
|
||||
return true;
|
||||
|
||||
case CommandId::CreateKeyfile:
|
||||
@@ -985,7 +988,7 @@ namespace VeraCrypt
|
||||
|
||||
if (cmdLine.ArgHash)
|
||||
{
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*cmdLine.ArgHash);
|
||||
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*cmdLine.ArgHash, false);
|
||||
RandomNumberGenerator::SetHash (cmdLine.ArgHash);
|
||||
}
|
||||
|
||||
@@ -1484,19 +1487,27 @@ namespace VeraCrypt
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
wxString UserInterface::VolumeTypeToString (VolumeType::Enum type, VolumeProtection::Enum protection) const
|
||||
wxString UserInterface::VolumeTypeToString (VolumeType::Enum type, bool truecryptMode, VolumeProtection::Enum protection) const
|
||||
{
|
||||
wxString sResult;
|
||||
switch (type)
|
||||
{
|
||||
case VolumeType::Normal:
|
||||
return LangString[protection == VolumeProtection::HiddenVolumeReadOnly ? "OUTER" : "NORMAL"];
|
||||
sResult = LangString[protection == VolumeProtection::HiddenVolumeReadOnly ? "OUTER" : "NORMAL"];
|
||||
break;
|
||||
|
||||
case VolumeType::Hidden:
|
||||
return LangString["HIDDEN"];
|
||||
sResult = LangString["HIDDEN"];
|
||||
break;
|
||||
|
||||
default:
|
||||
return L"?";
|
||||
sResult = L"?";
|
||||
break;
|
||||
}
|
||||
|
||||
if (truecryptMode)
|
||||
sResult = wxT("TrueCrypt-") + sResult;
|
||||
return sResult;
|
||||
}
|
||||
|
||||
#define VC_CONVERT_EXCEPTION(NAME) if (dynamic_cast<NAME*> (ex)) throw (NAME&) *ex;
|
||||
@@ -1565,6 +1576,8 @@ namespace VeraCrypt
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenKeyfileAlreadyExists);
|
||||
VC_CONVERT_EXCEPTION (SecurityTokenKeyfileNotFound);
|
||||
VC_CONVERT_EXCEPTION (SystemException);
|
||||
VC_CONVERT_EXCEPTION (UnsupportedAlgoInTrueCryptMode);
|
||||
VC_CONVERT_EXCEPTION (UnsupportedTrueCryptFormat);
|
||||
throw *ex;
|
||||
}
|
||||
}
|
||||
|
||||
10
src/Main/UserInterface.h
Executable file → Normal file
10
src/Main/UserInterface.h
Executable file → Normal file
@@ -29,7 +29,7 @@ namespace VeraCrypt
|
||||
virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const = 0;
|
||||
virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const = 0;
|
||||
virtual void BeginBusyState () const = 0;
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const = 0;
|
||||
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), shared_ptr <Hash> currentHash = shared_ptr <Hash>(), bool truecryptMode = false, shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const = 0;
|
||||
virtual void CheckRequirementsForMountingVolume () const;
|
||||
virtual void CloseExplorerWindows (shared_ptr <VolumeInfo> mountedVolume) const;
|
||||
virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const = 0;
|
||||
@@ -44,7 +44,7 @@ namespace VeraCrypt
|
||||
virtual void DoShowString (const wxString &str) const = 0;
|
||||
virtual void DoShowWarning (const wxString &message) const = 0;
|
||||
virtual void EndBusyState () const = 0;
|
||||
virtual wxString ExceptionToMessage (const exception &ex) const;
|
||||
static wxString ExceptionToMessage (const exception &ex);
|
||||
virtual void ExportSecurityTokenKeyfile () const = 0;
|
||||
virtual shared_ptr <GetStringFunctor> GetAdminPasswordRequestHandler () = 0;
|
||||
virtual const UserPreferences &GetPreferences () const { return Preferences; }
|
||||
@@ -79,7 +79,7 @@ namespace VeraCrypt
|
||||
virtual WaitThreadUI* GetWaitThreadUI(WaitThreadRoutine *pRoutine) const { return new WaitThreadUI(pRoutine);}
|
||||
virtual wxDateTime VolumeTimeToDateTime (VolumeTime volumeTime) const { return wxDateTime ((time_t) (volumeTime / 1000ULL / 1000 / 10 - 134774ULL * 24 * 3600)); }
|
||||
virtual wxString VolumeTimeToString (VolumeTime volumeTime) const;
|
||||
virtual wxString VolumeTypeToString (VolumeType::Enum type, VolumeProtection::Enum protection) const;
|
||||
virtual wxString VolumeTypeToString (VolumeType::Enum type, bool truecryptMode, VolumeProtection::Enum protection) const;
|
||||
|
||||
Event PreferencesUpdatedEvent;
|
||||
|
||||
@@ -100,8 +100,8 @@ namespace VeraCrypt
|
||||
virtual void OnWarning (EventArgs &args);
|
||||
virtual bool ProcessCommandLine ();
|
||||
|
||||
virtual wxString ExceptionToString (const Exception &ex) const;
|
||||
virtual wxString ExceptionTypeToString (const std::type_info &ex) const;
|
||||
static wxString ExceptionToString (const Exception &ex);
|
||||
static wxString ExceptionTypeToString (const std::type_info &ex);
|
||||
|
||||
UserPreferences Preferences;
|
||||
UserInterfaceType::Enum InterfaceType;
|
||||
|
||||
Reference in New Issue
Block a user