// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell http://www.novell.com
+// Copyright (C) 2004, 2007-2008 Novell, Inc (http://www.novell.com)
//
using NUnit.Framework;
public class SHA384Test : HashAlgorithmTest {
[SetUp]
- protected override void SetUp ()
+ public override void SetUp ()
{
hash = SHA384.Create ();
}
+ // the hash algorithm only exists as a managed implementation
+ public override bool ManagedHashImplementation {
+ get { return true; }
+ }
+
// test vectors from NIST FIPS 186-2
private string input1 = "abc";
public void FIPS186_a (string testName, SHA384 hash, byte[] input, byte[] result)
{
byte[] output = hash.ComputeHash (input);
- AssertEquals (testName + ".a.1", result, output);
- AssertEquals (testName + ".a.2", result, hash.Hash);
+ Assert.AreEqual (result, output, testName + ".a.1");
+ Assert.AreEqual (result, hash.Hash, testName + ".a.2");
// required or next operation will still return old hash
hash.Initialize ();
}
public void FIPS186_b (string testName, SHA384 hash, byte[] input, byte[] result)
{
byte[] output = hash.ComputeHash (input, 0, input.Length);
- AssertEquals (testName + ".b.1", result, output);
- AssertEquals (testName + ".b.2", result, hash.Hash);
+ 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 ();
}
{
MemoryStream ms = new MemoryStream (input);
byte[] output = hash.ComputeHash (ms);
- AssertEquals (testName + ".c.1", result, output);
- AssertEquals (testName + ".c.2", result, hash.Hash);
+ 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 ();
}
byte[] output = hash.TransformFinalBlock (input, 0, input.Length);
// LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue !
// AssertEquals( testName + ".d.1", result, output );
- AssertEquals (testName + ".d", result, hash.Hash);
+ 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 ();
}
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);
+ Assert.IsNotNull (output, testName + ".e.1");
+ Assert.AreEqual (result, hash.Hash, testName + ".e.2");
// required or next operation will still return old hash
hash.Initialize ();
}
// try to build the default implementation
SHA384 hash = SHA384.Create ();
- AssertEquals ("SHA384.Create()", hash.ToString (), defaultSHA384);
+ Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create()");
// try to build, in every way, a SHA384 implementation
hash = SHA384.Create ("SHA384");
- AssertEquals ("SHA384.Create('SHA384')", hash.ToString (), defaultSHA384);
+ Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create('SHA384')");
hash = SHA384.Create ("SHA-384");
- AssertEquals ("SHA384.Create('SHA-384')", hash.ToString (), defaultSHA384);
+ Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create('SHA-384')");
}
[Test]
{
// try to build invalid implementation
hash = SHA384.Create ("InvalidHash");
- AssertNull ("SHA384.Create('InvalidHash')", hash);
+ Assert.IsNull (hash, "SHA384.Create('InvalidHash')");
}
[Test]
public virtual void StaticInfo ()
{
string className = hash.ToString ();
- AssertEquals (className + ".HashSize", 384, hash.HashSize);
- AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize);
- AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize);
+ Assert.AreEqual (384, hash.HashSize, className + ".HashSize");
+ Assert.AreEqual (1, hash.InputBlockSize, className + ".InputBlockSize");
+ Assert.AreEqual (1, hash.OutputBlockSize, className + ".OutputBlockSize");
}
}