Exemple #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);
        }
Exemple #2
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);
        }