"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/Forms/EncryptionOptionsWizardPage.cpp" (10 Oct 2018, 4627 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "EncryptionOptionsWizardPage.cpp" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.18_Source_vs_1.19_Source.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #include "System.h"
   14 #include "Volume/EncryptionTest.h"
   15 #include "Volume/Hash.h"
   16 #include "Main/GraphicUserInterface.h"
   17 #include "BenchmarkDialog.h"
   18 #include "EncryptionOptionsWizardPage.h"
   19 #include "EncryptionTestDialog.h"
   20 
   21 namespace VeraCrypt
   22 {
   23     EncryptionOptionsWizardPage::EncryptionOptionsWizardPage (wxPanel* parent)
   24         : EncryptionOptionsWizardPageBase (parent)
   25     {
   26 
   27         EncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms();
   28         foreach (shared_ptr <EncryptionAlgorithm> ea, EncryptionAlgorithms)
   29         {
   30             if (!ea->IsDeprecated())
   31                 EncryptionAlgorithmChoice->Append (ea->GetName(true), ea.get());
   32         }
   33 
   34         EncryptionAlgorithmChoice->Select (0);
   35 
   36         Hashes = Hash::GetAvailableAlgorithms();
   37         foreach (shared_ptr <Hash> hash, Hashes)
   38         {
   39             if (!hash->IsDeprecated())
   40                 HashChoice->Append (hash->GetName(), hash.get());
   41         }
   42 
   43         HashChoice->Select (0);
   44         OnEncryptionAlgorithmSelected();
   45 
   46     }
   47 
   48     shared_ptr <EncryptionAlgorithm> EncryptionOptionsWizardPage::GetEncryptionAlgorithm () const
   49     {
   50         return Gui->GetSelectedData <EncryptionAlgorithm> (EncryptionAlgorithmChoice)->GetNew();
   51     }
   52 
   53     shared_ptr <Hash> EncryptionOptionsWizardPage::GetHash () const
   54     {
   55         return Gui->GetSelectedData <Hash> (HashChoice)->GetNew();
   56     }
   57 
   58     void EncryptionOptionsWizardPage::OnBenchmarkButtonClick (wxCommandEvent& event)
   59     {
   60         BenchmarkDialog dialog (this);
   61         dialog.ShowModal();
   62     }
   63 
   64     void EncryptionOptionsWizardPage::OnEncryptionAlgorithmSelected ()
   65     {
   66         FreezeScope freeze (this);
   67 
   68         shared_ptr <EncryptionAlgorithm> ea = GetEncryptionAlgorithm();
   69         CipherList ciphers = ea->GetCiphers();
   70 
   71         if (ciphers.size() == 1)
   72         {
   73             EncryptionAlgorithmHyperlink->SetLabel (StringFormatter (LangString["MORE_INFO_ABOUT"], ea->GetName()));
   74 
   75             if (typeid (*ea) == typeid (AES))
   76                 EncryptionAlgorithmStaticText->SetLabel (LangString["AES_HELP"]);
   77             else if (typeid (*ea) == typeid (Serpent))
   78                 EncryptionAlgorithmStaticText->SetLabel (LangString["SERPENT_HELP"]);
   79             else if (typeid (*ea) == typeid (Twofish))
   80                 EncryptionAlgorithmStaticText->SetLabel (LangString["TWOFISH_HELP"]);
   81             else if (typeid (*ea) == typeid (Camellia))
   82                 EncryptionAlgorithmStaticText->SetLabel (LangString["CAMELLIA_HELP"]);
   83             else if (typeid (*ea) == typeid (Kuznyechik))
   84                 EncryptionAlgorithmStaticText->SetLabel (LangString["KUZNYECHIK_HELP"]);
   85             else
   86                 EncryptionAlgorithmStaticText->SetLabel (L"");
   87         }
   88         else
   89         {
   90             if (ciphers.size() == 2)
   91             {
   92                 EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["TWO_LAYER_CASCADE_HELP"],
   93                     ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8,
   94                     ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8));
   95             }
   96             else if (ciphers.size() == 3)
   97             {
   98                 EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["THREE_LAYER_CASCADE_HELP"],
   99                     ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8,
  100                     ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8,
  101                     ciphers[2]->GetName(), (int) ciphers[2]->GetKeySize() * 8));
  102             }
  103             else
  104                 EncryptionAlgorithmStaticText->SetLabel (L"");
  105 
  106             EncryptionAlgorithmHyperlink->SetLabel (_("More information"));
  107         }
  108 
  109         Layout();
  110     }
  111 
  112     void EncryptionOptionsWizardPage::OnEncryptionAlgorithmHyperlinkClick (wxHyperlinkEvent& event)
  113     {
  114         if (GetEncryptionAlgorithm()->GetCiphers().size() == 1)
  115             Gui->OpenHomepageLink (this, wxString (GetEncryptionAlgorithm()->GetName()).Lower());
  116         else
  117             Gui->OpenHomepageLink (this, L"cascades");
  118     }
  119 
  120     void EncryptionOptionsWizardPage::OnHashHyperlinkClick (wxHyperlinkEvent& event)
  121     {
  122         Gui->OpenHomepageLink (this, L"hashalgorithms");
  123     }
  124 
  125     void EncryptionOptionsWizardPage::OnTestButtonClick (wxCommandEvent& event)
  126     {
  127         EncryptionTestDialog dialog (this);
  128         dialog.ShowModal();
  129     }
  130 
  131     void EncryptionOptionsWizardPage::SetEncryptionAlgorithm (shared_ptr <EncryptionAlgorithm> algorithm)
  132     {
  133         if (algorithm)
  134         {
  135             EncryptionAlgorithmChoice->SetStringSelection (algorithm->GetName(true));
  136             OnEncryptionAlgorithmSelected ();
  137         }
  138     }
  139 
  140     void EncryptionOptionsWizardPage::SetHash (shared_ptr <Hash> hash)
  141     {
  142         if (hash)
  143             HashChoice->SetStringSelection (hash->GetName());
  144     }
  145 }