mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 02:58:02 -06:00
* Add basic strcture needed for EMV implementation * Add demo EMV functionality with C code pasted in a very dirty and unsafe way. NOT FINAL * Refactor IccExtractor Structure * Fix Makefile * fix include file * move global variables from h to c * revert to memcpy * fix icc data recovery functions * Add EMV functionalities on windows * Make EMVToken structures like SecurityToken * Define constants instead of hard coded values * Token structures created with inheritance * refactor TokenKeyfile to use inherit. + polymor. * add Token.h + Token.cpp in modules in VS2010 * Add a comment at each use of SecurityToken class or objects * SecurityTokenKeyfilesDialog preparation * Implemennt GetAvailableTokens in Token class on windows * merge * up (patching for Windows) * foreach Token.cpp corrected * Display EMV keyfiles on first window in graphic interface * Add token to Windows UI * EMVToken selection on OKButton on Linux * Keyfile.cpp optimization * Move getKeyfileData in the token class * EMV::Token GetAvailableKeyfiles() base * Move getKeyfileData in the token class on unix * Remove test comments * Warnings resolved * RemoveeSecurityTokenLibraryNotInitialized exception if at least one emv token is detected * Adding new files * Remove old files and add the new version to the windows project * Change make_shared to shared_ptr constructor * IccExtractor integration working on linux * Throwing card not EMV execption * catch error when not EMV type in EMVToken::GetAvailableKeyfiles * Change types to compile on windows * list all keyfiles, security keyfiles and emv keyfiles in command line * Change type to be coherent and remove old todo comments * Remove todo comments * Change indentation and resolve a bug from previous commit * Use polymorphism for GetKeyfileData and add export option for EMVTokens on Linux * Linux : Allow to export EMV Tokens in command lines, Windows : Disable the delete button when EMV Keyfiles are selected * Remove SlotId from TokenInfo as it is already in Token * Correct errors on Linux * Disable delete option if one EMV Token is selected on Linux * Fix bug enabling delete button if nothing is selected * emv data used as reference then burnt * use of normal files in linux corrected * help updated * help updated for export functionnality * option EMV added to graphic interface but not yet working * Bug fix : Allow to use multiple EMV on windows * EMV Option added to UserPreferences * EMV Option working for Linux * EMV option added to Windows (not working yet) * [NOT TESTED] EMV option for Windows * Working EMV option on Windows * EMV Option for data extraction working for volume creation * EMV Option for data extraction working for Mount * EMV Option for data extraction working for mounting favorites volumes * EMV Option for extraction working for Changing volume password, Set Derivation Key Algorithm and Add or remove keyfile from volume * Windows : re-checking EMV Option when getting data * Removing error catches in the IccDataExtractor classe (It only throws error now). Changing GetPan signature to resemble the other functions signatures more * Changing EMV errors - Only throwing ICCExtractionException from outside of the ICC module. - Catching all TLVExceptions and PCSCExceptions to throw the right ICCExtractionException - Deleting APDU exceptions. * First version of the documentation * Adding function pointers for winscard library (but it crashes VeraCrypt) * Debugging function pointers * The import of the library on windows work as expected now * Reverting EMVToken.cpp changes used to test to library import * Searching for the System32 path instead of hard codding it * Fixing the bug were VeraCrypt crashes if there is no readers when "add Token files" is clicked * Winscard library not initialized in object constructor anymore to delay it after EMVOption check * Remove winscard lib from windows dependencies * Properly displaying errors * Adding a dot in Language.xml * Catching TLVException * Removing unused code * Remove unusefull comments * Trying to fix 0x1f error * Update IccDataExtractor.cpp * Delete History.xml * Fix get data without get pan * Cleanup code * changes for linux compilation but linking not working * error handling for linux * erasing emv data * Burn PAN * Burn PAN from memory * Uncomment selfcheck before merging master * burn corrected * EMV errors handling for Linux * EMV working for Linux CLI * Doc : Winscard Linux package and VeraCrypt versions --------- Co-authored-by: doriandu45 <d45.poubelle@gmail.com> Co-authored-by: red4game <redemgaiming@gmail.com> Co-authored-by: Brice.Namy <brice.namy@insa-rennes.fr> Co-authored-by: vocthor <pieceo108@gmail.com> Co-authored-by: vocthor <67202139+vocthor@users.noreply.github.com> Co-authored-by: Andrei COCAN <andrei.cocan@insa-rennes.fr> Co-authored-by: AndreiCocan <95496161+AndreiCocan@users.noreply.github.com> Co-authored-by: francoisLEROUX <francois3443@gmail.com>
253 lines
7.9 KiB
C++
253 lines
7.9 KiB
C++
/*
|
|
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 "MountOptionsDialog.h"
|
|
|
|
namespace VeraCrypt
|
|
{
|
|
#ifdef TC_MACOSX
|
|
|
|
bool MountOptionsDialog::ProcessEvent(wxEvent& event)
|
|
{
|
|
if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event))
|
|
return true;
|
|
else
|
|
return MountOptionsDialogBase::ProcessEvent(event);
|
|
}
|
|
#endif
|
|
|
|
MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options, const wxString &title, bool disableMountOptions)
|
|
: MountOptionsDialogBase (parent, wxID_ANY, wxString()
|
|
#ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing
|
|
, wxDefaultPosition, wxSize (-1,-1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
|
|
#endif
|
|
), Options (options)
|
|
{
|
|
if (!title.empty())
|
|
this->SetTitle (title);
|
|
else if (options.Path && !options.Path->IsEmpty())
|
|
this->SetTitle (StringFormatter (LangString["ENTER_PASSWORD_FOR"], wstring (*options.Path)));
|
|
else
|
|
this->SetTitle (LangString["ENTER_TC_VOL_PASSWORD"]);
|
|
|
|
if (disableMountOptions)
|
|
OptionsButton->Show (false);
|
|
|
|
|
|
#ifdef TC_MACOSX
|
|
GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (this);
|
|
#endif
|
|
|
|
PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
|
|
PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));
|
|
|
|
if (options.Path && options.Path->HasTrueCryptExtension() && !disableMountOptions
|
|
&& !options.TrueCryptMode && (options.Pim <= 0))
|
|
{
|
|
PasswordPanel->SetTrueCryptMode (true);
|
|
}
|
|
|
|
PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
|
|
|
|
#ifdef __WXGTK__
|
|
FilesystemOptionsSizer->Remove (FilesystemSpacer);
|
|
OptionsPanel->Show (false);
|
|
Fit();
|
|
Layout();
|
|
SetMinSize (GetSize());
|
|
#endif
|
|
|
|
NoFilesystemCheckBox->SetValidator (wxGenericValidator (&Options.NoFilesystem));
|
|
RemovableCheckBox->SetValidator (wxGenericValidator (&Options.Removable));
|
|
PartitionInSystemEncryptionScopeCheckBox->SetValidator (wxGenericValidator (&Options.PartitionInSystemEncryptionScope));
|
|
|
|
TransferDataToWindow();
|
|
|
|
if (Options.MountPoint && !Options.MountPoint->IsEmpty())
|
|
MountPointTextCtrl->SetValue (wstring (*Options.MountPoint));
|
|
|
|
FilesystemOptionsTextCtrl->SetValue (Options.FilesystemOptions);
|
|
|
|
ReadOnlyCheckBox->SetValue (Options.Protection == VolumeProtection::ReadOnly);
|
|
BackupHeaderCheckBox->SetValidator (wxGenericValidator (&Options.UseBackupHeaders));
|
|
ProtectionCheckBox->SetValue (Options.Protection == VolumeProtection::HiddenVolumeReadOnly);
|
|
|
|
OptionsButtonLabel = OptionsButton->GetLabel();
|
|
OptionsButton->SetLabel (OptionsButtonLabel + L" >");
|
|
OptionsPanel->Show (false);
|
|
|
|
ProtectionPasswordPanel = new VolumePasswordPanel (ProtectionSizer->GetStaticBox(), &options, options.ProtectionPassword, true, options.ProtectionKeyfiles, false, true, true, false, true, true, LangString["IDT_HIDDEN_PROT_PASSWD"]);
|
|
ProtectionPasswordPanel->TopOwnerParent = this;
|
|
ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND);
|
|
|
|
UpdateDialog();
|
|
Center();
|
|
}
|
|
|
|
void MountOptionsDialog::OnInitDialog (wxInitDialogEvent& event)
|
|
{
|
|
PasswordPanel->SetFocusToPasswordTextCtrl();
|
|
}
|
|
|
|
void MountOptionsDialog::OnMountPointButtonClick (wxCommandEvent& event)
|
|
{
|
|
DirectoryPath dir = Gui->SelectDirectory (this, wxEmptyString, false);
|
|
if (!dir.IsEmpty())
|
|
MountPointTextCtrl->SetValue (wstring (dir));
|
|
}
|
|
|
|
void MountOptionsDialog::OnOKButtonClick (wxCommandEvent& event)
|
|
{
|
|
bool bUnsupportedKdf = false;
|
|
|
|
/* verify that PIM values are valid before continuing*/
|
|
int Pim = PasswordPanel->GetVolumePim();
|
|
int ProtectionPim = (!ReadOnlyCheckBox->IsChecked() && ProtectionCheckBox->IsChecked())?
|
|
ProtectionPasswordPanel->GetVolumePim() : 0;
|
|
|
|
/* invalid PIM: set focus to PIM field and stop processing */
|
|
if (-1 == Pim || (PartitionInSystemEncryptionScopeCheckBox->IsChecked() && Pim > MAX_BOOT_PIM_VALUE))
|
|
{
|
|
PasswordPanel->SetFocusToPimTextCtrl();
|
|
return;
|
|
}
|
|
|
|
if (-1 == ProtectionPim || (PartitionInSystemEncryptionScopeCheckBox->IsChecked() && ProtectionPim > MAX_BOOT_PIM_VALUE))
|
|
{
|
|
ProtectionPasswordPanel->SetFocusToPimTextCtrl();
|
|
return;
|
|
}
|
|
|
|
TransferDataFromWindow();
|
|
|
|
try
|
|
{
|
|
Options.Password = PasswordPanel->GetPassword(Options.PartitionInSystemEncryptionScope);
|
|
}
|
|
catch (PasswordException& e)
|
|
{
|
|
Gui->ShowWarning (e);
|
|
return;
|
|
}
|
|
|
|
if (Options.PartitionInSystemEncryptionScope && Options.Password->Size() > VolumePassword::MaxLegacySize)
|
|
{
|
|
Gui->ShowWarning (StringFormatter (LangString["LINUX_SYSTEM_ENC_PW_LENGTH_NOTE"], (int) VolumePassword::MaxLegacySize));
|
|
return;
|
|
}
|
|
|
|
Options.Pim = Pim;
|
|
Options.Kdf = PasswordPanel->GetPkcs5Kdf(bUnsupportedKdf);
|
|
if (bUnsupportedKdf)
|
|
{
|
|
Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
|
|
return;
|
|
}
|
|
Options.TrueCryptMode = PasswordPanel->GetTrueCryptMode();
|
|
Options.Keyfiles = PasswordPanel->GetKeyfiles();
|
|
|
|
if (ReadOnlyCheckBox->IsChecked())
|
|
{
|
|
Options.Protection = VolumeProtection::ReadOnly;
|
|
}
|
|
else if (ProtectionCheckBox->IsChecked())
|
|
{
|
|
try
|
|
{
|
|
Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword(Options.TrueCryptMode);
|
|
}
|
|
catch (PasswordException& e)
|
|
{
|
|
Gui->ShowWarning (e);
|
|
return;
|
|
}
|
|
Options.Protection = VolumeProtection::HiddenVolumeReadOnly;
|
|
Options.ProtectionPim = ProtectionPim;
|
|
Options.ProtectionKdf = ProtectionPasswordPanel->GetPkcs5Kdf(Options.TrueCryptMode, bUnsupportedKdf);
|
|
if (bUnsupportedKdf)
|
|
{
|
|
Gui->ShowWarning (LangString ["ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE"]);
|
|
return;
|
|
}
|
|
Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles();
|
|
}
|
|
else
|
|
{
|
|
Options.Protection = VolumeProtection::None;
|
|
}
|
|
|
|
wstring mountPoint (MountPointTextCtrl->GetValue());
|
|
if (!mountPoint.empty())
|
|
Options.MountPoint = make_shared <DirectoryPath> (mountPoint);
|
|
|
|
Options.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();
|
|
Options.EMVOption = Gui->GetPreferences().ActivateEMVOption;
|
|
|
|
EndModal (wxID_OK);
|
|
}
|
|
|
|
void MountOptionsDialog::OnOptionsButtonClick (wxCommandEvent& event)
|
|
{
|
|
FreezeScope freeze (this);
|
|
OptionsPanel->Show (!OptionsPanel->IsShown());
|
|
UpdateDialog();
|
|
OptionsButton->SetLabel (OptionsButtonLabel + (OptionsPanel->IsShown() ? L" <" : L" >"));
|
|
}
|
|
|
|
void MountOptionsDialog::OnProtectionCheckBoxClick (wxCommandEvent& event)
|
|
{
|
|
FreezeScope freeze (this);
|
|
ProtectionPasswordPanel->Show (event.IsChecked());
|
|
Fit();
|
|
Layout();
|
|
ProtectionPasswordPanel->SetFocusToPasswordTextCtrl();
|
|
}
|
|
|
|
void MountOptionsDialog::OnProtectionHyperlinkClick (wxHyperlinkEvent& event)
|
|
{
|
|
Gui->OpenHomepageLink (this, L"hiddenvolprotection");
|
|
}
|
|
|
|
void MountOptionsDialog::UpdateDialog ()
|
|
{
|
|
FreezeScope freeze (this);
|
|
|
|
#ifdef TC_WINDOWS
|
|
FilesystemSizer->Show (false);
|
|
#else
|
|
FilesystemOptionsSizer->Show (!NoFilesystemCheckBox->IsChecked());
|
|
|
|
# ifdef TC_MACOSX
|
|
FilesystemOptionsStaticText->Show (false);
|
|
FilesystemOptionsTextCtrl->Show (false);
|
|
# endif
|
|
|
|
if (!Options.Path || Options.Path->IsEmpty())
|
|
{
|
|
MountPointTextCtrlStaticText->Show (false);
|
|
MountPointTextCtrl->Show (false);
|
|
MountPointButton->Show (false);
|
|
}
|
|
RemovableCheckBox->Show (false);
|
|
#endif
|
|
ProtectionSizer->Show (!ReadOnlyCheckBox->IsChecked());
|
|
ProtectionPasswordPanel->Show (!ReadOnlyCheckBox->IsChecked() && ProtectionCheckBox->IsChecked());
|
|
|
|
Fit();
|
|
Layout();
|
|
MainSizer->Fit( this );
|
|
}
|
|
}
|