Ejemplo n.º 1
0
        public void RotateRight_RotatesTwoBits_Rotated()
        {
            uint value    = 6;
            uint expected = 2147483649;

            Assert.AreEqual(expected, Word32Bits.RotateRight(value, 2));
        }
Ejemplo n.º 2
0
        public void RotateRight_RotatesOneBit_Rotated()
        {
            uint value    = 3;
            uint expected = 2147483649;

            Assert.AreEqual(expected, Word32Bits.RotateRight(value));
        }
Ejemplo n.º 3
0
        private uint[] Round(ITwofishMDS mds, uint[] K, int round)
        {
            uint F0 = TwofishFunction.h(mds, K[0], _key.SBox);
            uint F1 = TwofishFunction.h(mds, Word32Bits.RotateLeft(K[1], 8), _key.SBox);

            K[2] ^= F0 + F1 + _key.K[2 * round + 8];
            K[2]  = Word32Bits.RotateRight(K[2], 1);
            K[3]  = Word32Bits.RotateLeft(K[3], 1) ^ (F0 + 2 * F1 + _key.K[2 * round + 9]);
            return(K);
        }
Ejemplo n.º 4
0
        public static uint[] Inverse(uint[] x)
        {
            uint x1   = Word32Bits.RotateRight(x[2], 22) ^ x[3] ^ x[1] << 7;
            uint x2   = Word32Bits.RotateRight(x[0], 5) ^ x[1] ^ x[3];
            uint num1 = Word32Bits.RotateRight(x[3], 7);
            uint num2 = Word32Bits.RotateRight(x[1], 1);

            x[3] = num1 ^ x1 ^ x2 << 3;
            x[1] = num2 ^ x2 ^ x1;
            x[2] = Word32Bits.RotateRight(x1, 3);
            x[0] = Word32Bits.RotateRight(x2, 13);
            return(x);
        }