From 7ffce028d04a6b13ef762e2b89c34b688e8ca59d Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 31 May 2014 18:44:53 +0200 Subject: Add TrueCrypt 7.1a MacOSX/Linux specific source files. --- src/Main/Forms/EncryptionOptionsWizardPage.cpp | 137 +++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/Main/Forms/EncryptionOptionsWizardPage.cpp (limited to 'src/Main/Forms/EncryptionOptionsWizardPage.cpp') diff --git a/src/Main/Forms/EncryptionOptionsWizardPage.cpp b/src/Main/Forms/EncryptionOptionsWizardPage.cpp new file mode 100644 index 00000000..d321add2 --- /dev/null +++ b/src/Main/Forms/EncryptionOptionsWizardPage.cpp @@ -0,0 +1,137 @@ +/* + Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. + + Governed by the TrueCrypt License 3.0 the full text of which is contained in + the file License.txt included in TrueCrypt binary and source code distribution + packages. +*/ + +#include "System.h" +#include "Volume/EncryptionTest.h" +#include "Volume/Hash.h" +#include "Main/GraphicUserInterface.h" +#include "BenchmarkDialog.h" +#include "EncryptionOptionsWizardPage.h" +#include "EncryptionTestDialog.h" + +namespace TrueCrypt +{ + EncryptionOptionsWizardPage::EncryptionOptionsWizardPage (wxPanel* parent) + : EncryptionOptionsWizardPageBase (parent) + { + + EncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); + foreach (shared_ptr ea, EncryptionAlgorithms) + { + if (!ea->IsDeprecated()) + EncryptionAlgorithmChoice->Append (ea->GetName(), ea.get()); + } + + EncryptionAlgorithmChoice->Select (0); + + Hashes = Hash::GetAvailableAlgorithms(); + foreach (shared_ptr hash, Hashes) + { + if (!hash->IsDeprecated()) + HashChoice->Append (hash->GetName(), hash.get()); + } + + HashChoice->Select (0); + OnEncryptionAlgorithmSelected(); + + } + + shared_ptr EncryptionOptionsWizardPage::GetEncryptionAlgorithm () const + { + return Gui->GetSelectedData (EncryptionAlgorithmChoice)->GetNew(); + } + + shared_ptr EncryptionOptionsWizardPage::GetHash () const + { + return Gui->GetSelectedData (HashChoice)->GetNew(); + } + + void EncryptionOptionsWizardPage::OnBenchmarkButtonClick (wxCommandEvent& event) + { + BenchmarkDialog dialog (this); + dialog.ShowModal(); + } + + void EncryptionOptionsWizardPage::OnEncryptionAlgorithmSelected () + { + FreezeScope freeze (this); + + shared_ptr ea = GetEncryptionAlgorithm(); + CipherList ciphers = ea->GetCiphers(); + + if (ciphers.size() == 1) + { + EncryptionAlgorithmHyperlink->SetLabel (StringFormatter (LangString["MORE_INFO_ABOUT"], ea->GetName())); + + if (typeid (*ea) == typeid (AES)) + EncryptionAlgorithmStaticText->SetLabel (LangString["AES_HELP"]); + else if (typeid (*ea) == typeid (Serpent)) + EncryptionAlgorithmStaticText->SetLabel (LangString["SERPENT_HELP"]); + else if (typeid (*ea) == typeid (Twofish)) + EncryptionAlgorithmStaticText->SetLabel (LangString["TWOFISH_HELP"]); + else + EncryptionAlgorithmStaticText->SetLabel (L""); + } + else + { + if (ciphers.size() == 2) + { + EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["TWO_LAYER_CASCADE_HELP"], + ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8, + ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8)); + } + else if (ciphers.size() == 3) + { + EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["THREE_LAYER_CASCADE_HELP"], + ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8, + ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8, + ciphers[2]->GetName(), (int) ciphers[2]->GetKeySize() * 8)); + } + else + EncryptionAlgorithmStaticText->SetLabel (L""); + + EncryptionAlgorithmHyperlink->SetLabel (_("More information")); + } + + Layout(); + } + + void EncryptionOptionsWizardPage::OnEncryptionAlgorithmHyperlinkClick (wxHyperlinkEvent& event) + { + if (GetEncryptionAlgorithm()->GetCiphers().size() == 1) + Gui->OpenHomepageLink (this, wxString (GetEncryptionAlgorithm()->GetName()).Lower()); + else + Gui->OpenHomepageLink (this, L"cascades"); + } + + void EncryptionOptionsWizardPage::OnHashHyperlinkClick (wxHyperlinkEvent& event) + { + Gui->OpenHomepageLink (this, L"hashalgorithms"); + } + + void EncryptionOptionsWizardPage::OnTestButtonClick (wxCommandEvent& event) + { + EncryptionTestDialog dialog (this); + dialog.ShowModal(); + } + + void EncryptionOptionsWizardPage::SetEncryptionAlgorithm (shared_ptr algorithm) + { + if (algorithm) + { + EncryptionAlgorithmChoice->SetStringSelection (algorithm->GetName()); + OnEncryptionAlgorithmSelected (); + } + } + + void EncryptionOptionsWizardPage::SetHash (shared_ptr hash) + { + if (hash) + HashChoice->SetStringSelection (hash->GetName()); + } +} -- cgit v1.2.3