public void TestInvoke() { using CryptoContext cryptoContext = CryptoContext.CreateDefault(); RandomOracle oracle = new HashRandomOracle(cryptoContext.HashAlgorithmProvider); byte[] firstQuery = { 235, 12, 13, 72, 138, 13, 62, 13, 39, 147, 198, 173, 23, 87, 27, 99 }; byte[] secondQuery = { 84, 23, 123, 85, 62, 28, 54, 98, 187, 238, 18, 5, 78, 1, 78, 243 }; EnumerableAssert.AreNotEqual( oracle.Invoke(secondQuery).Take(10), oracle.Invoke(firstQuery).Take(10) ); }
public void TestInvoke() { using (CryptoContext cryptoContext = CryptoContext.CreateDefault()) { RandomOracle oracle = new HashRandomOracle(cryptoContext.HashAlgorithm); byte[] firstQuery = { 235, 12, 13, 72, 138, 13, 62, 13, 39, 147, 198, 173, 23, 87, 27, 99 }; byte[] secondQuery = { 84, 23, 123, 85, 62, 28, 54, 98, 187, 238, 18, 5, 78, 1, 78, 243 }; byte[] firstResponse = oracle.Invoke(firstQuery).Take(10).ToArray(); byte[] secondResponse = oracle.Invoke(secondQuery).Take(10).ToArray(); CollectionAssert.AreNotEqual(firstResponse, secondResponse); } }
public void TestThreadsafe() { using (CryptoContext cryptoContext = CryptoContext.CreateDefault()) { RandomOracle oracle = new HashRandomOracle(cryptoContext.HashAlgorithmProvider.CreateThreadsafe()); byte[] query = new[] { (byte)0x34, (byte)0x2f, (byte)0xab, (byte)0x25, (byte)0x33 }; byte[] expected = oracle.Invoke(query).Take(20).ToArray(); int count = 1000; Parallel.For(0, 2, i => { for (int j = 0; j < count; ++j) { byte[] result = oracle.Invoke(query).Take(20).ToArray(); CollectionAssert.AreEqual(expected, result); } }); } }