示例#1
0
        private void btnMNZCAP_Click(object sender, EventArgs e)
        {
            int maxi = 0, maxj = 0, max = 33;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 32; j++)
                {
                    for (int t = 0; t < 4; t++)
                    {
                        W[t] = Word.Parse("0000 0000 0000 0000 0000 0000 0000 0000");
                    }

                    W[i].SetBit('1', j);

                    Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]);

                    int cnt = Serpent.NonZeroColumnNumber(W);

                    if (cnt == 2)
                    {
                        max  = cnt;
                        maxi = i;
                        maxj = j;

                        MessageBox.Show(string.Format("Max: {0}\nWord: {1}\nBit: {2}", max, maxi, maxj));
                    }
                }
            }

            //MessageBox.Show(string.Format("Max: {0}\nWord: {1}\nBit: {2}",max,maxi,maxj));
        }
示例#2
0
        private void btnPerm_Click(object sender, EventArgs e)
        {
            ParseWandO();

            Serpent.ApplySerpentPermutation(ref W[0], ref W[1], ref W[2], ref W[3]);

            FillO(W);
        }
示例#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!");
            }
        }