示例#1
0
        private void SetComboParams(SymmetricEngines Engine)
        {
            cbCipherMode.Enabled = true;
            cbKeySize.Enabled    = true;
            cbKeySize.Items.Clear();
            cbRounds.Enabled = true;
            cbRounds.Items.Clear();

            switch (Engine)
            {
            case SymmetricEngines.ChaCha:
            case SymmetricEngines.Salsa:
                cbCipherMode.Enabled = false;
                cbKeySize.Items.Add(KeySizes.K128);
                cbKeySize.Items.Add(KeySizes.K256);
                ComboHelper.SetSelectedIndex(cbKeySize, 1);
                ComboHelper.AddEnumRange(cbRounds, typeof(RoundCounts), 8, 30);
                ComboHelper.SetSelectedIndex(cbRounds, 6);
                break;

            case SymmetricEngines.RHX:
                ComboHelper.SetSelectedIndex(cbEngines, 0);
                cbKeySize.Items.Clear();
                cbKeySize.Items.Add(KeySizes.K128);
                cbKeySize.Items.Add(KeySizes.K192);
                cbKeySize.Items.Add(KeySizes.K256);
                cbKeySize.Items.Add(KeySizes.K512);
                ComboHelper.SetSelectedIndex(cbKeySize, 2);
                ComboHelper.AddEnumRange(cbRounds, typeof(RoundCounts), 10, 38);
                ComboHelper.SetSelectedIndex(cbRounds, 2);
                break;

            case SymmetricEngines.SHX:
                cbKeySize.Items.Add(KeySizes.K128);
                cbKeySize.Items.Add(KeySizes.K192);
                cbKeySize.Items.Add(KeySizes.K256);
                cbKeySize.Items.Add(KeySizes.K512);
                ComboHelper.SetSelectedIndex(cbKeySize, 2);
                cbRounds.Items.Add(RoundCounts.R32);
                cbRounds.Items.Add(RoundCounts.R40);
                cbRounds.Items.Add(RoundCounts.R48);
                cbRounds.Items.Add(RoundCounts.R56);
                cbRounds.Items.Add(RoundCounts.R64);
                ComboHelper.SetSelectedIndex(cbRounds, 0);
                break;

            case SymmetricEngines.THX:
                cbKeySize.Items.Add(KeySizes.K128);
                cbKeySize.Items.Add(KeySizes.K192);
                cbKeySize.Items.Add(KeySizes.K256);
                cbKeySize.Items.Add(KeySizes.K512);
                ComboHelper.SetSelectedIndex(cbKeySize, 2);
                ComboHelper.AddEnumRange(cbRounds, typeof(RoundCounts), 16, 32);
                ComboHelper.SetSelectedIndex(cbRounds, 0);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            SetRounds();
        }