public void FIPS186_b(string testName, SHA256 hash, byte[] input, byte[] result) { byte[] output = hash.ComputeHash (input, 0, input.Length); Assert.AreEqual (result, output, testName + ".b.1"); Assert.AreEqual (result, hash.Hash, testName + ".b.2"); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_c(string testName, SHA256 hash, byte[] input, byte[] result) { MemoryStream ms = new MemoryStream (input); byte[] output = hash.ComputeHash (ms); Assert.AreEqual (result, output, testName + ".c.1"); Assert.AreEqual (result, hash.Hash, testName + ".c.2"); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_d(string testName, SHA256 hash, byte[] input, byte[] result) { byte[] output = hash.TransformFinalBlock (input, 0, input.Length); // LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue ! // AssertEquals( testName + ".d.1", result, output ); Assert.IsNotNull (output, testName + ".d.1"); Assert.AreEqual (result, hash.Hash, testName + ".d.2"); // required or next operation will still return old hash hash.Initialize (); }
// // public methods // public override void Initialize() { if (_impl != null) { _impl.Initialize(); } else { InitializeState(); // Zeroize potentially sensitive information. Array.Clear(_buffer, 0, _buffer.Length); Array.Clear(_W, 0, _W.Length); } }
public void FIPS186_a (string testName, SHA256 hash, byte[] input, byte[] result) { byte[] output = hash.ComputeHash (input); AssertEquals (testName + ".a.1", result, output); AssertEquals (testName + ".a.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_e (string testName, SHA256 hash, byte[] input, byte[] result) { byte[] copy = new byte [input.Length]; for (int i=0; i < input.Length - 1; i++) hash.TransformBlock (input, i, 1, copy, i); byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1); // LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue ! // AssertEquals (testName + ".e.1", result, output); AssertEquals (testName + ".e", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }