Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -35,7 +35,6 @@ using System.Text;
namespace MonoTests.System.Security.Cryptography {
#if NET_2_0
public class HS160 : HMACSHA1 {
public int BlockSize {
@@ -43,7 +42,6 @@ namespace MonoTests.System.Security.Cryptography {
set { base.BlockSizeValue = value; }
}
}
#endif
// References:
// a. The Keyed-Hash Message Authentication Code (HMAC)
@@ -90,28 +88,16 @@ public class HMACSHA1Test : KeyedHashAlgorithmTest {
Assert.AreEqual (160, algo.HashSize, "HMACSHA1.HashSize");
Assert.AreEqual (1, algo.InputBlockSize, "HMACSHA1.InputBlockSize");
Assert.AreEqual (1, algo.OutputBlockSize, "HMACSHA1.OutputBlockSize");
Assert.AreEqual (64, algo.Key.Length, "HMACSHA1.Key.Length");
Assert.AreEqual ("System.Security.Cryptography.HMACSHA1", algo.ToString (), "HMACSHA1.ToString()");
}
#if NET_2_0
[Test]
public void BlockSize ()
{
HS160 hmac = new HS160 ();
Assert.AreEqual (64, hmac.BlockSize, "BlockSizeValue");
}
#else
// this is legal in .NET 2.0 because HMACSHA1 derives from HMAC
[Test]
[ExpectedException (typeof (InvalidCastException))]
public void InvalidHashName ()
{
algo = new HMACSHA1 ();
algo.HashName = "MD5";
byte[] data = Encoding.Default.GetBytes ("MD5");
byte[] hmac = algo.ComputeHash (data);
}
#endif
public void Check (string testName, byte[] key, byte[] data, byte[] result)
{
@@ -126,11 +112,7 @@ public class HMACSHA1Test : KeyedHashAlgorithmTest {
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);
Assert.AreEqual (result, hmac, testName + "a1");
Assert.AreEqual (result, algo.Hash, testName + "a2");
@@ -138,11 +120,7 @@ public class HMACSHA1Test : KeyedHashAlgorithmTest {
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);
Assert.AreEqual (result, hmac, testName + "b1");
Assert.AreEqual (result, algo.Hash, testName + "b2");