Пример #1
0
        private void btnInvSBox_Click(object sender, EventArgs e)
        {
            ParseWandO();

            Serpent.ApplySerpentInvSBox(ref O[0], ref O[1], ref O[2], ref O[3], (int)nupSbox.Value);

            FillW(O);
        }
Пример #2
0
        private void btn55to3_Click(object sender, EventArgs e)
        {
            ParseWandO();

            Serpent.ApplySerpentInvSBox(ref O[0], ref O[1], ref O[2], ref O[3], 5);

            Serpent.ApplySerpentInvPermutation(ref O[0], ref O[1], ref O[2], ref O[3]);
            Serpent.ApplySerpentInvSBox(ref O[0], ref O[1], ref O[2], ref O[3], 4);

            Serpent.ApplySerpentInvPermutation(ref O[0], ref O[1], ref O[2], ref O[3]);
            Serpent.ApplySerpentInvSBox(ref O[0], ref O[1], ref O[2], ref O[3], 3);

            FillW(O);
        }
Пример #3
0
        private void btnAutoOpStart_Click(object sender, EventArgs e)
        {
            try
            {
                ParseWandO();

                for (int i = 0; i < lstAutoOpList.Items.Count; i++)
                {
                    string s = lstAutoOpList.Items[i].ToString();
                    if (s.Contains(" - "))
                    {
                        // S-Box
                        int rnd = int.Parse(s.Split(new string[] { " - " }, StringSplitOptions.None)[1]);

                        if (s.Contains("Inverse"))
                        {
                            // Inverse
                            Serpent.ApplySerpentInvSBox(ref W[0], ref W[1], ref W[2], ref W[3], rnd);
                        }
                        else
                        {
                            // Normal
                            Serpent.ApplySerpentSBox(ref W[0], ref W[1], ref W[2], ref W[3], rnd);
                        }
                    }
                    else
                    {
                        // Permutation
                        if (s.Contains("Inverse"))
                        {
                            // Inverse
                            Serpent.ApplySerpentInvPermutation(ref W[0], ref W[1], ref W[2], ref W[3]);
                        }
                        else
                        {
                            // Normal
                            Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]);
                        }
                    }
                }

                FillO(W);
            }
            catch
            {
                MessageBox.Show("There was an error!");
            }
        }