VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/VolumePasswordPanel.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-30 10:35:41 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-11-30 12:58:19 (GMT)
commitefa436974d8203485eec6faa1bf0116bb32f6fcd (patch)
tree97a5ef2eea0310a12db399151de7ca97dbd47ece /src/Main/Forms/VolumePasswordPanel.cpp
parentcfadb231d24bd292a6ea3708b776bde8f06e50ab (diff)
downloadVeraCrypt-efa436974d8203485eec6faa1bf0116bb32f6fcd.zip
VeraCrypt-efa436974d8203485eec6faa1bf0116bb32f6fcd.tar.gz
Linux/MacOSX: Implement Unicode passwords suppport. Make validation of parameters in GUI more robust.
Diffstat (limited to 'src/Main/Forms/VolumePasswordPanel.cpp')
-rw-r--r--src/Main/Forms/VolumePasswordPanel.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp
index 0313453..e55b09f 100644
--- a/src/Main/Forms/VolumePasswordPanel.cpp
+++ b/src/Main/Forms/VolumePasswordPanel.cpp
@@ -231,7 +231,7 @@ namespace VeraCrypt
#ifdef TC_WINDOWS
int len = GetWindowText (static_cast <HWND> (textCtrl->GetHandle()), passwordBuf, VolumePassword::MaxSize + 1);
- password.reset (new VolumePassword (passwordBuf, len));
+ password = ToUTF8Password (passwordBuf, len);
#else
wxString passwordStr (textCtrl->GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased
for (size_t i = 0; i < passwordStr.size() && i < VolumePassword::MaxSize; ++i)
@@ -239,19 +239,33 @@ namespace VeraCrypt
passwordBuf[i] = (wchar_t) passwordStr[i];
passwordStr[i] = L'X';
}
- password.reset (new VolumePassword (passwordBuf, passwordStr.size() <= VolumePassword::MaxSize ? passwordStr.size() : VolumePassword::MaxSize));
+ password = ToUTF8Password (passwordBuf, passwordStr.size() <= VolumePassword::MaxSize ? passwordStr.size() : VolumePassword::MaxSize);
#endif
return password;
}
- shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf () const
+ shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf (bool &bUnsupportedKdf) const
{
+ return GetPkcs5Kdf (GetTrueCryptMode(), bUnsupportedKdf);
+ }
+
+ shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf (bool bTrueCryptMode, bool &bUnsupportedKdf) const
+ {
+ bUnsupportedKdf = false;
try
{
- return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()), GetTrueCryptMode());
+ int index = Pkcs5PrfChoice->GetSelection ();
+ if ((wxNOT_FOUND == index) || (0 == index))
+ {
+ // auto-detection
+ return shared_ptr <Pkcs5Kdf> ();
+ }
+ else
+ return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()), bTrueCryptMode);
}
catch (ParameterIncorrect&)
{
+ bUnsupportedKdf = true;
return shared_ptr <Pkcs5Kdf> ();
}
}
@@ -419,7 +433,14 @@ namespace VeraCrypt
bool VolumePasswordPanel::PasswordsMatch () const
{
assert (ConfirmPasswordStaticText->IsShown());
- return *GetPassword (PasswordTextCtrl) == *GetPassword (ConfirmPasswordTextCtrl);
+ try
+ {
+ return *GetPassword (PasswordTextCtrl) == *GetPassword (ConfirmPasswordTextCtrl);
+ }
+ catch (PasswordException&)
+ {
+ return false;
+ }
}
void VolumePasswordPanel::WipeTextCtrl (wxTextCtrl *textCtrl)