/* Derived from source code of TrueCrypt 7.1a, which is Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ #include "System.h" #include #include #include "Core/Core.h" #include "Application.h" #include "CommandLineInterface.h" #include "LanguageStrings.h" #include "UserInterfaceException.h" namespace VeraCrypt { CommandLineInterface::CommandLineInterface (int argc, wchar_t** argv, UserInterfaceType::Enum interfaceType) : ArgCommand (CommandId::None), ArgFilesystem (VolumeCreationOptions::FilesystemType::Unknown), ArgNewPim (-1), ArgNoHiddenVolumeProtection (false), ArgPim (-1), ArgSize (0), ArgVolumeType (VolumeType::Unknown), ArgTrueCryptMode (false), StartBackgroundTask (false) { wxCmdLineParser parser; parser.SetCmdLine (argc, argv); parser.SetSwitchChars (L"-"); parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes")); parser.AddSwitch (L"", L"backup-headers", _("Backup volume headers")); parser.AddSwitch (L"", L"background-task", _("Start Background Task")); #ifdef TC_WINDOWS parser.AddSwitch (L"", L"cache", _("Cache passwords and keyfiles")); #endif parser.AddSwitch (L"C", L"change", _("Change password or keyfiles")); parser.AddSwitch (L"c", L"create", _("Create new volume")); parser.AddSwitch (L"", L"create-keyfile", _("Create new keyfile")); parser.AddSwitch (L"", L"delete-token-keyfiles", _("Delete security token keyfiles")); parser.AddSwitch (L"d", L"dismount", _("Dismount volume")); parser.AddSwitch (L"", L"display-password", _("Display password while typing")); parser.AddOption (L"", L"encryption", _("Encryption algorithm")); parser.AddSwitch (L"", L"explore", _("Open explorer window for mounted volume")); parser.AddSwitch (L"", L"export-token-keyfile",_("Export keyfile from security token")); parser.AddOption (L"", L"filesystem", _("Filesystem type")); parser.AddSwitch (L"f", L"force", _("Force mount/dismount/overwrite")); #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) parser.AddOption (L"", L"fs-options", _("Filesystem mount options")); #endif parser.AddOption (L"", L"hash", _("Hash algorithm")); parser.AddSwitch (L"h", L"help", _("Display detailed command line help"), wxCMD_LINE_OPTION_HELP); parser.AddSwitch (L"", L"import-token-keyfiles", _("Import keyfiles to security token")); parser.AddOption (L"k", L"keyfiles", _("Keyfiles")); parser.AddSwitch (L"l", L"list", _("List mounted volumes")); parser.AddSwitch (L"", L"list-token-keyfiles", _("List security token keyfiles")); parser.AddSwitch (L"", L"load-preferences", _("Load user preferences")); parser.AddSwitch (L"", L"mount", _("Mount volume interactively")); parser.AddOption (L"m", L"mount-options", _("VeraCrypt volume mount options")); parser.AddOption (L"", L"new-hash", _("New hash algorithm")); parser.AddOption (L"", L"new-keyfiles", _("New keyfiles")); parser.AddOption (L"", L"new-password", _("New password")); parser.AddOption (L"", L"new-pim", _("New PIM")); parser.AddSwitch (L"", L"non-interactive", _("Do not interact with user")); parser.AddSwitch (L"", L"stdin", _("Read password from standard input")); parser.AddOption (L"p", L"password", _("Password")); parser.AddOption (L"", L"pim", _("PIM")); parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume")); parser.AddOption (L"", L"protection-hash", _("Hash algorithm for protected hidden volume")); parser.AddOption (L"", L"protection-keyfiles", _("Keyfiles for protected hidden volume")); parser.AddOption (L"", L"protection-password", _("Password for protected hidden volume")); parser.AddOption (L"", L"protection-pim", _("PIM for protected hidden volume")); parser.AddOption (L"", L"random-source", _("Use file as source of random data")); parser.AddSwitch (L"", L"restore-headers", _("Restore volume headers")); parser.AddSwitch (L"", L"save-preferences", _("Save user preferences")); 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.AddSwitch (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")); parser.AddOption (L"", L"token-pin", _("Security token PIN")); parser.AddSwitch (L"v", L"verbose", _("Enable verbose output")); parser.AddSwitch (L"", L"version", _("Display version information")); parser.AddSwitch (L"", L"volume-properties", _("Display volume properties")); parser.AddOption (L"", L"volume-type", _("Volume type")); parser.AddParam ( _("Volume path"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddParam ( _("Mount point"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); wxString str; bool param1IsVolume = false; bool param1IsMountedVolumeSpec = false; bool param1IsMountPoint = false; bool param1IsFile = false; if (parser.Parse () > 0) throw_err (_("Incorrect command line specified.")); if (parser.Found (L"help")) { ArgCommand = CommandId::Help; return; } if (parser.Found (L"text") && interfaceType != UserInterfaceType::Text) { wstring msg = wstring (_("Option -t or --text must be specified as the first argument.")); wcerr << msg << endl; throw_err (msg); } if (parser.Found (L"version")) { ArgCommand = CommandId::DisplayVersion; return; } // Preferences if (parser.Found (L"load-preferences")) { // Load preferences first to allow command line options to override them Preferences.Load(); ArgMountOptions = Preferences.DefaultMountOptions; } // Commands if (parser.Found (L"auto-mount", &str)) { CheckCommandSingle(); wxStringTokenizer tokenizer (str, L","); while (tokenizer.HasMoreTokens()) { wxString token = tokenizer.GetNextToken(); if (token == L"devices") { if (ArgCommand == CommandId::AutoMountFavorites) ArgCommand = CommandId::AutoMountDevicesFavorites; else ArgCommand = CommandId::AutoMountDevices; param1IsMountPoint = true; } else if (token == L"favorites") { if (ArgCommand == CommandId::AutoMountDevices) ArgCommand = CommandId::AutoMountDevicesFavorites; else ArgCommand = CommandId::AutoMountFavorites; } else { throw_err (LangString["UNKNOWN_OPTION"] + L": " + token); } } } if (parser.Found (L"backup-headers")) { CheckCommandSingle(); ArgCommand = CommandId::BackupHeaders; param1IsVolume = true; } if (parser.Found (L"change")) { CheckCommandSingle(); ArgCommand = CommandId::ChangePassword; param1IsVolume = true; } if (parser.Found (L"create")) { CheckCommandSingle(); ArgCommand = CommandId::CreateVolume; param1IsVolume = true; } if (parser.Found (L"create-keyfile")) { CheckCommandSingle(); ArgCommand = CommandId::CreateKeyfile; param1IsFile = true; } if (parser.Found (L"delete-token-keyfiles")) { CheckCommandSingle(); ArgCommand = CommandId::DeleteSecurityTokenKeyfiles; } if (parser.Found (L"dismount")) { CheckCommandSingle(); ArgCommand = CommandId::DismountVolumes; param1IsMountedVolumeSpec = true; } if (parser.Found (L"export-token-keyfile")) { CheckCommandSingle(); ArgCommand = CommandId::ExportSecurityTokenKeyfile; } if (parser.Found (L"import-token-keyfiles")) { CheckCommandSingle(); ArgCommand = CommandId::ImportSecurityTokenKeyfiles; } if (parser.Found (L"list")) { CheckCommandSingle(); ArgCommand = CommandId::ListVolumes; param1IsMountedVolumeSpec = true; } if (parser.Found (L"list-token-keyfiles")) { CheckCommandSingle(); ArgCommand = CommandId::ListSecurityTokenKeyfiles; } if (parser.Found (L"mount")) { CheckCommandSingle(); ArgCommand = CommandId::MountVolume; param1IsVolume = true; } if (parser.Found (L"save-preferences")) { CheckCommandSingle(); ArgCommand = CommandId::SavePreferences; } if (parser.Found (L"test")) { CheckCommandSingle(); ArgCommand = CommandId::Test; } if (parser.Found (L"volume-properties")) { CheckCommandSingle(); ArgCommand = CommandId::DisplayVolumeProperties; param1IsMountedVolumeSpec = true; } // Options if (parser.Found (L"background-task")) StartBackgroundTask = true; #ifdef TC_WINDOWS if (parser.Found (L"cache")) ArgMountOptions.CachePassword = true; #endif ArgDisplayPassword = parser.Found (L"display-password"); if (parser.Found (L"encryption", &str)) { ArgEncryptionAlgorithm.reset(); foreach (shared_ptr ea, EncryptionAlgorithm::GetAvailableAlgorithms()) { if (!ea->IsDeprecated() && wxString (ea->GetName()).IsSameAs (str, false)) ArgEncryptionAlgorithm = ea; } if (!ArgEncryptionAlgorithm) throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); } if (parser.Found (L"explore")) Preferences.OpenExplorerWindowAfterMount = true; if (parser.Found (L"filesystem", &str)) { if (str.IsSameAs (L"none", false)) { ArgMountOptions.NoFilesystem = true; ArgFilesystem = VolumeCreationOptions::FilesystemType::None; } else { ArgMountOptions.FilesystemType = wstring (str); if (str.IsSameAs (L"FAT", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::FAT; #ifdef TC_LINUX else if (str.IsSameAs (L"Ext2", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext2; else if (str.IsSameAs (L"Ext3", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext3; else if (str.IsSameAs (L"Ext4", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext4; else if (str.IsSameAs (L"NTFS", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::NTFS; else if (str.IsSameAs (L"exFAT", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::exFAT; #elif defined (TC_MACOSX) else if ( str.IsSameAs (L"HFS", false) || str.IsSameAs (L"HFS+", false) || str.IsSameAs (L"MacOsExt", false) ) { ArgFilesystem = VolumeCreationOptions::FilesystemType::MacOsExt; } else if (str.IsSameAs (L"exFAT", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::exFAT; #elif defined (TC_FREEBSD) || defined (TC_SOLARIS) else if (str.IsSameAs (L"UFS", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::UFS; #endif else ArgFilesystem = VolumeCreationOptions::FilesystemType::None; } } ArgForce = parser.Found (L"force"); ArgTrueCryptMode = parser.Found (L"truecrypt"); #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) if (parser.Found (L"fs-options", &str)) ArgMountOptions.FilesystemOptions = str; #endif if (parser.Found (L"hash", &str)) { ArgHash.reset(); foreach (shared_ptr hash, Hash::GetAvailableAlgorithms()) { wxString hashName (hash->GetName()); wxString hashAltName (hash->GetAltName()); if (hashName.IsSameAs (str, false) || hashAltName.IsSameAs (str, false)) ArgHash = hash; } if (!ArgHash) throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); } if (parser.Found (L"new-hash", &str)) { ArgNewHash.reset(); foreach (shared_ptr hash, Hash::GetAvailableAlgorithms()) { wxString hashName (hash->GetName()); wxString hashAltName (hash->GetAltName()); if (hashName.IsSameAs (str, false) || hashAltName.IsSameAs (str, false)) ArgNewHash = hash; } if (!ArgNewHash) throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); } if (parser.Found (L"keyfiles", &str)) ArgKeyfiles = ToKeyfileList (str); if (parser.Found (L"mount-options", &str)) { wxStringTokenizer tokenizer (str, L","); while (tokenizer.HasMoreTokens()) { wxString token = tokenizer.GetNextToken(); if (token == L"headerbak") ArgMountOptions.UseBackupHeaders = true; else if (token == L"nokernelcrypto") ArgMountOptions.NoKernelCrypto = true; else if (token == L"readonly" || token == L"ro") ArgMountOptions.Protection = VolumeProtection::ReadOnly; else if (token == L"system") ArgMountOptions.PartitionInSystemEncryptionScope = true; else if (token == L"timestamp" || token == L"ts") ArgMountOptions.PreserveTimestamps = false; #ifdef TC_WINDOWS else if (token == L"removable" || token == L"rm") ArgMountOptions.Removable = true; #endif else throw_err (LangString["UNKNOWN_OPTION"] + L": " + token); } } if (parser.Found (L"new-keyfiles", &str)) ArgNewKeyfiles = ToKeyfileList (str); if (parser.Found (L"new-password", &str)) ArgNewPassword = ToUTF8Password (str.c_str()); if (parser.Found (L"new-pim", &str)) { try { ArgNewPim = StringConverter::ToInt32 (wstring (str));
/*
 Derived from source code of TrueCrypt 7.1a, which is
 Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
 by the TrueCrypt License 3.0.

 Modifications and additions to the original source code (contained in this file)
 and all other portions of this file are Copyright (c) 2013-2017 IDRIX
 and are governed by the Apache License 2.0 the full text of which is
 contained in the file License.txt included in VeraCrypt binary and source
 code distribution packages.
*/

#include "System.h"
#include "Main/Main.h"
#include "Main/GraphicUserInterface.h"
#include "ChangePasswordDialog.h"
#include "WaitDialog.h"

namespace VeraCrypt
{
#ifdef TC_MACOSX

	bool ChangePasswordDialog::ProcessEvent(wxEvent& event)
	{
		if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event))
			return true;
		else
			return ChangePasswordDialogBase::ProcessEvent(event);
	}
#endif

	ChangePasswordDialog::ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles)
		: ChangePasswordDialogBase (parent), DialogMode (mode), Path (volumePath)
	{
		bool enableNewPassword = false;
		bool enableNewKeyfiles = false;
		bool enablePkcs5Prf = false;
		bool isTrueCryptFile = false;
		
		if (volumePath && volumePath->HasTrueCryptExtension ())
		{
			isTrueCryptFile = true;
		}

		switch (mode)
		{
		case Mode::ChangePasswordAndKeyfiles:
			enableNewPassword = true;
			enableNewKeyfiles = true;
			enablePkcs5Prf = true;
			SetTitle (_("Change Volume Password and Keyfiles"));
			break;

		case Mode::ChangeKeyfiles:
			enableNewKeyfiles = true;
			SetTitle (_("Add/Remove Keyfiles to/from Volume"));
			break;

		case Mode::RemoveAllKeyfiles:
			SetTitle (_("Remove All Keyfiles from Volume"));
			break;

		case Mode::ChangePkcs5Prf:
			enablePkcs5Prf = true;
			SetTitle (_("Change Header Key Derivation Algorithm"));
			break;

		default:
			throw ParameterIncorrect (SRC_POS);
		}
		
#ifdef TC_MACOSX
		GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (this);
#endif

		CurrentPasswordPanel = new VolumePasswordPanel (this, NULL, password, false, keyfiles, false, true, true, false, true, true);
		CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
		CurrentPasswordPanel->SetTrueCryptMode (isTrueCryptFile);
		CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND);

		NewPasswordPanel = new VolumePasswordPanel (this, NULL, newPassword, true, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
		NewPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
		NewPasswordPanelSizer->Add (NewPasswordPanel, 1, wxALL | wxEXPAND);

		if (mode == Mode::RemoveAllKeyfiles)
			NewSizer->Show (false);

		Layout();
		Fit();
		Center();

		OnPasswordPanelUpdate();
		CurrentPasswordPanel->SetFocusToPasswordTextCtrl();
	}

	ChangePasswordDialog::~ChangePasswordDialog ()
	{
		CurrentPasswordPanel->UpdateEvent.Disconnect (this);
		NewPasswordPanel->UpdateEvent.Disconnect (this);
	}

	void ChangePasswordDialog::OnOKButtonClick (wxCommandEvent& event)
	{
		// Avoid a GTK bug
		if (!OKButton->IsEnabled())
			return;

		try
		{
			bool bUnsupportedKdf = false;
			shared_ptr <Pkcs5Kdf> currentKdf = CurrentPasswordPanel->GetPkcs5Kdf(bUnsupportedKdf);
			if (bUnsupportedKdf)
			{
				Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
				return;
			}
			int currentPim = CurrentPasswordPanel->GetVolumePim();
			if (-1 == currentPim)
			{
				CurrentPasswordPanel->SetFocusToPimTextCtrl();
				return;
			}

			shared_ptr <VolumePassword> newPassword;
			int newPim = 0;
			if (DialogMode == Mode::ChangePasswordAndKeyfiles)
			{
				try
				{
					newPassword = NewPasswordPanel->GetPassword();
				}
				catch (PasswordException& e)
				{
					Gui->ShowWarning (e);
					NewPasswordPanel->SetFocusToPasswordTextCtrl();
					return;
				}
				newPim = NewPasswordPanel->GetVolumePim();
				if (-1 == newPim)
				{
					NewPasswordPanel->SetFocusToPimTextCtrl();
					return;
				}

				if (newPassword->Size() > 0)
				{
					if (newPassword->Size() < VolumePassword::WarningSizeThreshold)
					{
						if (newPim > 0 && newPim < 485)
						{
							Gui->ShowError ("PIM_REQUIRE_LONG_PASSWORD");
							return;
						}

						if (!Gui->AskYesNo (LangString ["PASSWORD_LENGTH_WARNING"], false, true))
						{
							NewPasswordPanel->SetFocusToPasswordTextCtrl();
							return;
						}
					}
					else if (newPim > 0 && newPim < 485)
					{
						if (!Gui->AskYesNo (LangString ["PIM_SMALL_WARNING"], false, true))
						{
							NewPasswordPanel->SetFocusToPimTextCtrl();
							return;
						}
					}
				}
			}
			else
			{
				newPassword = CurrentPasswordPanel->GetPassword();
				newPim = CurrentPasswordPanel->GetVolumePim();
			}

			shared_ptr <KeyfileList> newKeyfiles;
			if (DialogMode == Mode::ChangePasswordAndKeyfiles || DialogMode == Mode::ChangeKeyfiles)
				newKeyfiles = NewPasswordPanel->GetKeyfiles();
			else if (DialogMode != Mode::RemoveAllKeyfiles)
				newKeyfiles = CurrentPasswordPanel->GetKeyfiles();

			/* force the display of the random enriching interface */
			RandomNumberGenerator::SetEnrichedByUserStatus (false);
			Gui->UserEnrichRandomPool (this, NewPasswordPanel->GetPkcs5Kdf(bUnsupportedKdf) ? NewPasswordPanel->GetPkcs5Kdf(bUnsupportedKdf)->GetHash() : shared_ptr <Hash>());

			{
#ifdef TC_UNIX
				// Temporarily take ownership of a device if the user is not an administrator
				UserId origDeviceOwner ((uid_t) -1);

				if (!Core->HasAdminPrivileges() && Path->IsDevice())
				{
					origDeviceOwner = FilesystemPath (wstring (*Path)).GetOwner();
					Core->SetFileOwner (*Path, UserId (getuid()));
				}

				finally_do_arg2 (FilesystemPath, *Path, UserId, origDeviceOwner,
				{
					if (finally_arg2.SystemId != (uid_t) -1)
						Core->SetFileOwner (finally_arg, finally_arg2);
				});
#endif
				wxBusyCursor busy;
				ChangePasswordThreadRoutine routine(Path,	Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps,
					CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetVolumePim(), CurrentPasswordPanel->GetPkcs5Kdf(bUnsupportedKdf), CurrentPasswordPanel->GetTrueCryptMode(),CurrentPasswordPanel->GetKeyfiles(),
					newPassword, newPim, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(bUnsupportedKdf), NewPasswordPanel->GetHeaderWipeCount());
				Gui->ExecuteWaitThreadRoutine (this, &routine);
			}

			switch (DialogMode)
			{
			case Mode::ChangePasswordAndKeyfiles:
				Gui->ShowInfo ("PASSWORD_CHANGED");
				break;

			case Mode::ChangeKeyfiles:
			case Mode::RemoveAllKeyfiles:
				Gui->ShowInfo ("KEYFILE_CHANGED");
				break;

			case Mode::ChangePkcs5Prf:
				Gui->ShowInfo ("PKCS5_PRF_CHANGED");
				break;

			default:
				throw ParameterIncorrect (SRC_POS);
			}

			EndModal (wxID_OK);
		}
		catch (UnportablePassword &e)
		{
			Gui->ShowError (e);
			NewPasswordPanel->SetFocusToPasswordTextCtrl();
		}
		catch (PasswordException &e)
		{
			Gui->ShowWarning (e);
			CurrentPasswordPanel->SetFocusToPasswordTextCtrl();
		}
		catch (exception &e)
		{
			Gui->ShowError (e);
		}
	}

	void ChangePasswordDialog::OnPasswordPanelUpdate ()
	{
		bool ok = true;

		try
		{

			bool passwordEmpty = CurrentPasswordPanel->GetPassword()->IsEmpty();
			bool keyfilesEmpty = !CurrentPasswordPanel->GetKeyfiles() || CurrentPasswordPanel->GetKeyfiles()->empty();

			if (passwordEmpty && keyfilesEmpty)
				ok = false;

			if (CurrentPasswordPanel->GetVolumePim () == -1)
				ok = false;

			if (DialogMode == Mode::RemoveAllKeyfiles && (passwordEmpty || keyfilesEmpty))
				ok = false;

			if (DialogMode == Mode::ChangePasswordAndKeyfiles || DialogMode == Mode::ChangeKeyfiles)
			{
				bool newKeyfilesEmpty = !NewPasswordPanel->GetKeyfiles() || NewPasswordPanel->GetKeyfiles()->empty();

				if (DialogMode == Mode::ChangeKeyfiles
					&& ((passwordEmpty && newKeyfilesEmpty) || (keyfilesEmpty && newKeyfilesEmpty)))
					ok = false;

				if (DialogMode == Mode::ChangePasswordAndKeyfiles
					&& (	(NewPasswordPanel->GetPassword()->IsEmpty() && newKeyfilesEmpty)
						|| 	!NewPasswordPanel->PasswordsMatch()
						|| 	(NewPasswordPanel->GetVolumePim() == -1)
						)
					)
					ok = false;
			}
		}
		catch (PasswordException&)
		{
			ok = false;
		}

		OKButton->Enable (ok);

		if (DialogMode == Mode::ChangePasswordAndKeyfiles)
		{
			bool pimChanged = (CurrentPasswordPanel->GetVolumePim() != NewPasswordPanel->GetVolumePim());
			NewPasswordPanel->UpdatePimHelpText(pimChanged);
		}

	}
}