Annotation of truecrypt/main/forms/encryptionoptionswizardpage.cpp, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.