示例#1
0
        // verified
        private ListOfDiffPairs GetChosenPlaintexts(UInt64 diff)
        {
            var result = new ListOfDiffPairs();
            var plains = new UInt64[]
            {
                8293413307042899260,
                2417420169597379724,
                7391341682234711011,
                1294612218368839102,
                3427586664725945798,
                8120399254031000395,
                4954062227563315182,
                7287792347285229213,
                6369026791565508293,
                3497943451105456066,
                635651540614717595,
                466693664381143020
            };

            for (var i = 0; i < numberOfPlain; ++i)
            {
                var firstPlain   = randomNumberGenerator.GetNextUInt64();
                var secondPlain  = firstPlain ^ diff;
                var firstCipher  = feal4Encryptor.Encrypt(firstPlain, subKeys);
                var secondCipher = feal4Encryptor.Encrypt(secondPlain, subKeys);

                var first  = new PlainCipherPair64(firstPlain, firstCipher);
                var second = new PlainCipherPair64(secondPlain, secondCipher);
                result.Add(Tuple.Create(first, second));
            }
            return(result);
        }
示例#2
0
        // verified
        private static ListOfDiffPairs UndoLastRound(ListOfDiffPairs diffPairs, UInt32 subKey)
        {
            var result = new ListOfDiffPairs();

            for (var i = 0; i < numberOfPlain; ++i)
            {
                UInt32 firstCipherLeft  = Feal4Helper.GetLeftHalf(diffPairs[i].Item1.Cipher);
                UInt32 firstCipherRight = Feal4Helper.GetRightHalf(diffPairs[i].Item1.Cipher);

                UInt32 secondCipherLeft  = Feal4Helper.GetLeftHalf(diffPairs[i].Item2.Cipher);
                UInt32 secondCipherRight = Feal4Helper.GetRightHalf(diffPairs[i].Item2.Cipher);

                firstCipherLeft  = firstCipherRight;
                secondCipherLeft = secondCipherRight;

                firstCipherRight  = Feal4Helper.Fbox(firstCipherLeft ^ subKey) ^ (Feal4Helper.GetLeftHalf(diffPairs[i].Item1.Cipher));
                secondCipherRight = Feal4Helper.Fbox(secondCipherLeft ^ subKey) ^ (Feal4Helper.GetLeftHalf(diffPairs[i].Item2.Cipher));

                var firstObj = new PlainCipherPair <UInt64>(diffPairs[i].Item1.Plain,
                                                            Feal4Helper.Combine32BitHalfs(firstCipherLeft, firstCipherRight));
                var secondObj = new PlainCipherPair <UInt64>(diffPairs[i].Item2.Plain,
                                                             Feal4Helper.Combine32BitHalfs(secondCipherLeft, secondCipherRight));

                result.Add(Tuple.Create(firstObj, secondObj));
            }
            return(result);
        }
示例#3
0
        // verified
        private ListOfDiffPairs UndoFinalOperation(ListOfDiffPairs data)
        {
            var result = new ListOfDiffPairs();

            foreach (var item in data)
            {
                var firstLeftCipher  = Feal4Helper.GetLeftHalf(item.Item1.Cipher);
                var firstRightCipher = Feal4Helper.GetRightHalf(item.Item1.Cipher) ^ firstLeftCipher;

                var secondLeftCipher  = Feal4Helper.GetLeftHalf(item.Item2.Cipher);
                var secondRightCipher = Feal4Helper.GetRightHalf(item.Item2.Cipher) ^ secondLeftCipher;

                var firstRecombined  = Feal4Helper.Combine32BitHalfs(firstLeftCipher, firstRightCipher);
                var secondRecombined = Feal4Helper.Combine32BitHalfs(secondLeftCipher, secondRightCipher);

                var firstObj  = new PlainCipherPair64(item.Item1.Plain, firstRecombined);
                var secondObj = new PlainCipherPair64(item.Item2.Plain, secondRecombined);
                result.Add(Tuple.Create(firstObj, secondObj));
            }
            return(result);
        }