private byte[] EncryptRDX(byte[] Key, byte[] Data) { int blocks = Data.Length / 16; byte[] outputData = new byte[Data.Length]; using (RDX transform = new RDX()) { transform.Initialize(true, new KeyParams(Key)); for (int i = 0; i < blocks; i++) transform.Transform(Data, i * 16, outputData, i * 16); } return outputData; }
private void VectorTest(byte[] Key, byte[] Input, byte[] Output) { byte[] outBytes = new byte[Input.Length]; byte[] outBytes2 = new byte[Input.Length]; using (RDX engine = new RDX(Input.Length)) { engine.Initialize(true, new KeyParams(Key)); engine.Transform(Input, outBytes); if (Compare.AreEqual(outBytes, Output) == false) throw new Exception("Rijndael: Encrypted arrays are not equal! Expected: " + HexConverter.ToString(Output) + " Received: " + HexConverter.ToString(outBytes)); engine.Initialize(false, new KeyParams(Key)); engine.Transform(Output, outBytes); if (Compare.AreEqual(outBytes, Input) == false) throw new Exception("Rijndael: Decrypted arrays are not equal! Expected: " + HexConverter.ToString(Input) + " Received: " + HexConverter.ToString(outBytes)); } }
private void MonteCarloTest(byte[] Key, byte[] Input, byte[] Output) { byte[] outBytes = new byte[Input.Length]; Array.Copy(Input, 0, outBytes, 0, outBytes.Length); using (RDX engine = new RDX()) { engine.Initialize(true, new KeyParams(Key)); for (int i = 0; i != 10000; i++) engine.Transform(outBytes, outBytes); } if (Compare.AreEqual(outBytes, Output) == false) throw new Exception("AES MonteCarlo: Arrays are not equal! Expected: " + HexConverter.ToString(Output) + " Received: " + HexConverter.ToString(outBytes)); using (RDX engine = new RDX()) { engine.Initialize(false, new KeyParams(Key)); for (int i = 0; i != 10000; i++) engine.Transform(outBytes, outBytes); } if (Compare.AreEqual(outBytes, Input) == false) throw new Exception("AES MonteCarlo: Arrays are not equal! Expected: " + HexConverter.ToString(Input) + " Received: " + HexConverter.ToString(outBytes)); }