Ejemplo n.º 1
0
        public byte[] diff(byte[] block, GenericBlockCipher cipher)
        {
            for (int j = 0; j < block.Length; j++)
            {
                block[j] = (byte)(block[j] ^ cipher.Key[j % cipher.Key.Length]);
            }

            return(block);
        }
Ejemplo n.º 2
0
        public void Generic_GenericBlock()
        {
            GenericBlockCipher gbc = new GenericBlockCipher();

            gbc.DiffuseFunction = diff;
            gbc.ConfuseFunction = conf;

            gbc.InverseDiffuseFunction = diff;
            gbc.InverseConfuseFunction = conf;

            gbc.Key = BitConverter.GetBytes(0x133457799BBCDFF1);
            byte[] clear = BitConverter.GetBytes(0x0123456789ABCDEF);
            gbc.BlockSize = gbc.Key.Length * 8;//this is to get this working without padding

            byte[] cipher = gbc.Encrypt(clear);

            CollectionAssert.AreNotEqual(clear, cipher);

            byte[] plain = gbc.Decrypt(cipher);

            CollectionAssert.AreEqual(clear, plain);
        }
Ejemplo n.º 3
0
        public byte[] conf(byte[] block, GenericBlockCipher cipher)
        {
            Array.Reverse(block);

            return(block);
        }