// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004, 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
protected HMACSHA1 algo;
+ [SetUp]
+ protected override void SetUp ()
+ {
+ hash = HMACSHA1.Create ();
+ (hash as KeyedHashAlgorithm).Key = new byte [8];
+ }
+
[Test]
public void Constructors ()
{
// this is legal in .NET 2.0 because HMACSHA1 derives from HMAC
[Test]
[ExpectedException (typeof (InvalidCastException))]
- public void Exceptions ()
+ public void InvalidHashName ()
{
algo = new HMACSHA1 ();
algo.HashName = "MD5";
byte[] data = Encoding.Default.GetBytes ("MD5");
- byte[] hmac = hash.ComputeHash (data);
- Fail ("Expected InvalidCastException but got none");
+ byte[] hmac = algo.ComputeHash (data);
}
#endif
public void CheckA (string testName, byte[] key, byte[] data, byte[] result)
{
+#if NET_2_0
+ algo = new HMACSHA1 (key, true);
+#else
algo = new HMACSHA1 (key);
+#endif
byte[] hmac = algo.ComputeHash (data);
AssertEquals (testName + "a1", result, hmac);
AssertEquals (testName + "a2", result, algo.Hash);
public void CheckB (string testName, byte[] key, byte[] data, byte[] result)
{
+#if NET_2_0
+ algo = new HMACSHA1 (key, false);
+#else
algo = new HMACSHA1 (key);
+#endif
byte[] hmac = algo.ComputeHash (data, 0, data.Length);
AssertEquals (testName + "b1", result, hmac);
AssertEquals (testName + "b2", result, algo.Hash);