Beispiel #1
0
        private void MonteCarloTest(byte[] Key, byte[] Input, byte[] Output)
        {
            byte[] outBytes = new byte[Input.Length];
            Array.Copy(Input, 0, outBytes, 0, outBytes.Length);

            using (RHX engine = new RHX())
            {
                engine.Initialize(true, new KeyParams(Key));

                for (int i = 0; i != 10000; i++)
                {
                    engine.Transform(outBytes, outBytes);
                }
            }

            if (Evaluate.AreEqual(outBytes, Output) == false)
            {
                throw new Exception("AES MonteCarlo: Arrays are not equal! Expected: " + HexConverter.ToString(Output) + " Received: " + HexConverter.ToString(outBytes));
            }

            using (RHX engine = new RHX())
            {
                engine.Initialize(false, new KeyParams(Key));

                for (int i = 0; i != 10000; i++)
                {
                    engine.Transform(outBytes, outBytes);
                }
            }

            if (Evaluate.AreEqual(outBytes, Input) == false)
            {
                throw new Exception("AES MonteCarlo: Arrays are not equal! Expected: " + HexConverter.ToString(Input) + " Received: " + HexConverter.ToString(outBytes));
            }
        }
Beispiel #2
0
        private void VectorTest(byte[] Key, byte[] Input, byte[] Output)
        {
            byte[] outBytes = new byte[Input.Length];

            using (RHX engine = new RHX())
            {
                engine.Initialize(true, new KeyParams(Key));
                engine.Transform(Input, outBytes);

                if (Evaluate.AreEqual(outBytes, Output) == false)
                {
                    throw new Exception("AES: Encrypted arrays are not equal! Expected: " + HexConverter.ToString(Output) + " Received: " + HexConverter.ToString(outBytes));
                }

                engine.Initialize(false, new KeyParams(Key));
                engine.Transform(Output, outBytes);

                if (Evaluate.AreEqual(outBytes, Input) == false)
                {
                    throw new Exception("AES: Decrypted arrays are not equal! Expected: " + HexConverter.ToString(Input) + " Received: " + HexConverter.ToString(outBytes));
                }
            }
        }
Beispiel #3
0
        private byte[] EncryptRDX(byte[] Key, byte[] Data)
        {
            int blocks = Data.Length / 16;

            byte[] outputData = new byte[Data.Length];

            using (RHX transform = new RHX())
            {
                transform.Initialize(true, new KeyParams(Key));

                for (int i = 0; i < blocks; i++)
                {
                    transform.Transform(Data, i * 16, outputData, i * 16);
                }
            }

            return(outputData);
        }