summary refs log tree commit diff
path: root/crypto/test
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 16:46:07 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-21 16:46:07 +0700
commit95c58fd065df852598412fa8b7d06c3cee72c29c (patch)
tree01d8a520a72b008656881a37ec88d0ab2c98c361 /crypto/test
parentMerge branch 'pkix-validator-throw' of git://github.com/jstedfast/bc-csharp i... (diff)
parentPort HMac optimisation using Memoable digests from bc-java. (diff)
downloadBouncyCastle.NET-ed25519-95c58fd065df852598412fa8b7d06c3cee72c29c.tar.xz
Merge branch 'feature/threefish-skein-memoable-sm3' of git://github.com/timw/bc-csharp into timw-feature/threefish-skein-memoable-sm3
Conflicts:
	crypto/crypto.mdp
	crypto/src/util/Arrays.cs
Diffstat (limited to 'crypto/test')
-rw-r--r--crypto/test/src/crypto/test/CipherTest.cs2
-rw-r--r--crypto/test/src/crypto/test/DigestTest.cs44
-rw-r--r--crypto/test/src/crypto/test/MD2DigestTest.cs227
-rw-r--r--crypto/test/src/crypto/test/MD4DigestTest.cs203
-rw-r--r--crypto/test/src/crypto/test/MD5DigestTest.cs204
-rw-r--r--crypto/test/src/crypto/test/RegressionTest.cs6
-rw-r--r--crypto/test/src/crypto/test/RipeMD128DigestTest.cs177
-rw-r--r--crypto/test/src/crypto/test/RipeMD160DigestTest.cs173
-rw-r--r--crypto/test/src/crypto/test/RipeMD256DigestTest.cs126
-rw-r--r--crypto/test/src/crypto/test/RipeMD320DigestTest.cs147
-rw-r--r--crypto/test/src/crypto/test/SHA1DigestTest.cs134
-rw-r--r--crypto/test/src/crypto/test/SHA224DigestTest.cs224
-rw-r--r--crypto/test/src/crypto/test/SHA256DigestTest.cs232
-rw-r--r--crypto/test/src/crypto/test/SHA384DigestTest.cs233
-rw-r--r--crypto/test/src/crypto/test/SHA512DigestTest.cs203
-rw-r--r--crypto/test/src/crypto/test/SkeinDigestTest.cs303
-rw-r--r--crypto/test/src/crypto/test/SkeinMacTest.cs174
-rw-r--r--crypto/test/src/crypto/test/Sm3DigestTest.cs74
-rw-r--r--crypto/test/src/crypto/test/Threefish1024Test.cs74
-rw-r--r--crypto/test/src/crypto/test/Threefish256Test.cs59
-rw-r--r--crypto/test/src/crypto/test/Threefish512Test.cs64
-rw-r--r--crypto/test/src/crypto/test/TigerDigestTest.cs106
-rw-r--r--crypto/test/src/crypto/test/WhirlpoolDigestTest.cs124
23 files changed, 1441 insertions, 1872 deletions
diff --git a/crypto/test/src/crypto/test/CipherTest.cs b/crypto/test/src/crypto/test/CipherTest.cs
index a893e0239..d9c085d44 100644
--- a/crypto/test/src/crypto/test/CipherTest.cs
+++ b/crypto/test/src/crypto/test/CipherTest.cs
@@ -42,7 +42,7 @@ namespace Org.BouncyCastle.Crypto.Tests
 				//
 				// state tests
 				//
-				byte[] buf = new byte[16];
+				byte[] buf = new byte[_engine.GetBlockSize()];
 
 				try
 				{
diff --git a/crypto/test/src/crypto/test/DigestTest.cs b/crypto/test/src/crypto/test/DigestTest.cs
index 533e87181..930979643 100644
--- a/crypto/test/src/crypto/test/DigestTest.cs
+++ b/crypto/test/src/crypto/test/DigestTest.cs
@@ -2,6 +2,7 @@ using System;
 
 using Org.BouncyCastle.Crypto;
 
+using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
@@ -35,9 +36,9 @@ namespace Org.BouncyCastle.Crypto.Tests
 
 			for (int i = 0; i < input.Length - 1; i++)
 			{
-				byte[] m = toByteArray(input[i]);
+				byte[] msg = toByteArray(input[i]);
 
-				vectorTest(digest, i, resBuf, m, Hex.Decode(results[i]));
+				vectorTest(digest, i, resBuf, msg, Hex.Decode(results[i]));
 			}
 
 			byte[] lastV = toByteArray(input[input.Length - 1]);
@@ -68,6 +69,45 @@ namespace Org.BouncyCastle.Crypto.Tests
 			{
 				Fail("failing second clone vector test", results[results.Length - 1], Hex.ToHexString(resBuf));
 			}
+
+			//
+			// memo test
+			//
+			IMemoable m = (IMemoable)digest;
+
+			digest.BlockUpdate(lastV, 0, lastV.Length/2);
+
+			// copy the Digest
+			IMemoable copy1 = m.Copy();
+			IMemoable copy2 = copy1.Copy();
+
+			digest.BlockUpdate(lastV, lastV.Length/2, lastV.Length - lastV.Length/2);
+			digest.DoFinal(resBuf, 0);
+
+			if (!AreEqual(lastDigest, resBuf))
+			{
+				Fail("failing memo vector test", results[results.Length - 1], Hex.ToHexString(resBuf));
+			}
+
+			m.Reset(copy1);
+
+			digest.BlockUpdate(lastV, lastV.Length/2, lastV.Length - lastV.Length/2);
+			digest.DoFinal(resBuf, 0);
+
+			if (!AreEqual(lastDigest, resBuf))
+			{
+				Fail("failing memo reset vector test", results[results.Length - 1], Hex.ToHexString(resBuf));
+			}
+
+			IDigest md = (IDigest)copy2;
+
+			md.BlockUpdate(lastV, lastV.Length/2, lastV.Length - lastV.Length/2);
+			md.DoFinal(resBuf, 0);
+
+			if (!AreEqual(lastDigest, resBuf))
+			{
+				Fail("failing memo copy vector test", results[results.Length - 1], Hex.ToHexString(resBuf));
+			}
 		}
 
 		private byte[] toByteArray(
diff --git a/crypto/test/src/crypto/test/MD2DigestTest.cs b/crypto/test/src/crypto/test/MD2DigestTest.cs
index e9d2cb88f..963a57e49 100644
--- a/crypto/test/src/crypto/test/MD2DigestTest.cs
+++ b/crypto/test/src/crypto/test/MD2DigestTest.cs
@@ -7,198 +7,61 @@ using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
-
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
+	/**
      * standard vector test for MD2
      * from RFC1319 by B.Kaliski of RSA Laboratories April 1992
      *
      */
-    [TestFixture]
-    public class MD2DigestTest
-		: ITest
-    {
-        static private string testVec1 = "";
-        static private string resVec1 = "8350e5a3e24c153df2275c9f80692773";
-        static private string testVec2 = "61";
-        static private string resVec2 = "32ec01ec4a6dac72c0ab96fb34c0b5d1";
-        static private string testVec3 = "616263";
-        static private string resVec3 = "da853b0d3f88d99b30283a69e6ded6bb";
-        static private string testVec4 = "6d65737361676520646967657374";
-        static private string resVec4 = "ab4f496bfb2a530b219ff33031fe06b0";
-        static private string testVec5 = "6162636465666768696a6b6c6d6e6f707172737475767778797a";
-        static private string resVec5 = "4e8ddff3650292ab5a4108c3aa47940b";
-        static private string testVec6 = "4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839";
-        static private string resVec6 = "da33def2a42df13975352846c30338cd";
-        static private string testVec7 = "3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930";
-        static private string resVec7 = "d5976f79d83d3a0dc9806c3c66f3efd8";
-
-		public string Name
-        {
-			get { return "MD2"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new MD2Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-            //
-            // test 1
-            //
-            byte[]  bytes = Hex.Decode(testVec1);
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec5);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec5.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    //System.err.println(
-                    "MD2 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec5
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-            //
-            // test 6
-            //
-            bytes = Hex.Decode(testVec6);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec6.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 6"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec6
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-            //
-            // test 7
-            //
-            bytes = Hex.Decode(testVec7);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec7.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD2 failing standard vector test 7"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec7
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
+	[TestFixture]
+	public class MD2DigestTest
+		: DigestTest
+	{
+		static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		static string[] digests =
+		{ 
+			"8350e5a3e24c153df2275c9f80692773",
+			"32ec01ec4a6dac72c0ab96fb34c0b5d1",
+			"da853b0d3f88d99b30283a69e6ded6bb",
+			"ab4f496bfb2a530b219ff33031fe06b0",
+			"4e8ddff3650292ab5a4108c3aa47940b",
+			"da33def2a42df13975352846c30338cd",
+			"d5976f79d83d3a0dc9806c3c66f3efd8" 
+		};
+
+		internal MD2DigestTest()
+			: base(new MD2Digest(), messages, digests)
+		{
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new MD2Digest((MD2Digest)digest);
+		}
 
 		public static void Main(
-            string[] args)
-        {
-            ITest test = new MD2DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+			string[] args)
+		{
+			RunTest(new MD2DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
 			Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/MD4DigestTest.cs b/crypto/test/src/crypto/test/MD4DigestTest.cs
index 89b5d7949..a4062e92d 100644
--- a/crypto/test/src/crypto/test/MD4DigestTest.cs
+++ b/crypto/test/src/crypto/test/MD4DigestTest.cs
@@ -9,168 +9,51 @@ using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
-     * standard vector test for MD4 from RFC 1320.
+	/**
+	 * standard vector test for MD4 from RFC 1320.
      */
-    [TestFixture]
-    public class MD4DigestTest
-		: ITest
-    {
-//        static private string testVec1 = "";
-        static private string resVec1 = "31d6cfe0d16ae931b73c59d7e0c089c0";
-
-        static private string testVec2 = "61";
-        static private string resVec2 = "bde52cb31de33e46245e05fbdbd6fb24";
-
-        static private string testVec3 = "616263";
-        static private string resVec3 = "a448017aaf21d8525fc10ae87aa6729d";
-
-        static private string testVec4 = "3132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930";
-        static private string resVec4 = "e33b4ddc9c38f2199c3e7b164fcc0536";
-
-        public string Name
-        {
-			get { return "MD4"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest  digest = new MD4Digest();
-            byte[]  resBuf = new byte[digest.GetDigestSize()];
-            string  resStr;
-
-            //
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[]  bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length/2);
-
-            // clone the IDigest
-            IDigest d = new MD4Digest((MD4Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD4 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new MD4DigestTest();
-            ITestResult result = test.Perform();
-
-            Console.WriteLine(result);
-        }
+	[TestFixture]
+	public class MD4DigestTest
+		: DigestTest
+	{
+		static private string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		static private string[] digests =
+		{
+			"31d6cfe0d16ae931b73c59d7e0c089c0",
+			"bde52cb31de33e46245e05fbdbd6fb24",
+			"a448017aaf21d8525fc10ae87aa6729d",
+			"e33b4ddc9c38f2199c3e7b164fcc0536"
+		};
+
+		internal MD4DigestTest()
+			: base(new MD4Digest(), messages, digests)
+		{
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new MD4Digest((MD4Digest)digest);
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new MD4DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
-
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/MD5DigestTest.cs b/crypto/test/src/crypto/test/MD5DigestTest.cs
index b38e06391..75cc9f8a4 100644
--- a/crypto/test/src/crypto/test/MD5DigestTest.cs
+++ b/crypto/test/src/crypto/test/MD5DigestTest.cs
@@ -7,169 +7,53 @@ using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
-
 namespace Org.BouncyCastle.Crypto.Tests
 {
-	/// <remarks>Standard vector test for MD5 from "Handbook of Applied Cryptography", page 345.</remarks>
-    [TestFixture]
-    public class MD5DigestTest
-		: ITest
-    {
-//        static private string testVec1 = "";
-        static private string resVec1 = "d41d8cd98f00b204e9800998ecf8427e";
-
-        static private string testVec2 = "61";
-        static private string resVec2 = "0cc175b9c0f1b6a831c399e269772661";
-
-        static private string testVec3 = "616263";
-        static private string resVec3 = "900150983cd24fb0d6963f7d28e17f72";
-
-        static private string testVec4 = "6162636465666768696a6b6c6d6e6f707172737475767778797a";
-        static private string resVec4 = "c3fcd3d76192e4007dfb496cca67e13b";
-
-        public string Name
-        {
-			get { return "MD5"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new MD5Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-            //
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[] bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length/2);
-
-            // clone the IDigest
-            IDigest d = new MD5Digest((MD5Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "MD5 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new MD5DigestTest();
-            ITestResult result = test.Perform();
-
-            Console.WriteLine(result);
-        }
+	/**
+	 * standard vector test for MD5 from "Handbook of Applied Cryptography", page 345.
+     */
+	[TestFixture]
+	public class MD5DigestTest
+		: DigestTest
+	{
+		static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdefghijklmnopqrstuvwxyz"
+		};
+
+		static string[] digests =
+		{
+			"d41d8cd98f00b204e9800998ecf8427e",
+			"0cc175b9c0f1b6a831c399e269772661",
+			"900150983cd24fb0d6963f7d28e17f72",
+			"c3fcd3d76192e4007dfb496cca67e13b"
+		};
+
+		internal MD5DigestTest()
+			: base(new MD5Digest(), messages, digests)
+		{
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new MD5Digest((MD5Digest)digest);
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new MD5DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
-
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/RegressionTest.cs b/crypto/test/src/crypto/test/RegressionTest.cs
index 5a13a1f96..4b639005e 100644
--- a/crypto/test/src/crypto/test/RegressionTest.cs
+++ b/crypto/test/src/crypto/test/RegressionTest.cs
@@ -39,6 +39,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             new SkipjackTest(),
             new BlowfishTest(),
             new TwofishTest(),
+            new Threefish256Test(),
+            new Threefish512Test(),
+            new Threefish1024Test(),
+            new SkeinDigestTest(),
+            new SkeinMacTest(),
             new Cast5Test(),
             new Cast6Test(),
             new Gost28147Test(),
@@ -112,6 +117,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             new SipHashTest(),
             new Poly1305Test(),
             new OcbTest(),
+			new Sm3DigestTest()
         };
 
         public static void Main(
diff --git a/crypto/test/src/crypto/test/RipeMD128DigestTest.cs b/crypto/test/src/crypto/test/RipeMD128DigestTest.cs
index 61d70f3f8..8cf0d7e0c 100644
--- a/crypto/test/src/crypto/test/RipeMD128DigestTest.cs
+++ b/crypto/test/src/crypto/test/RipeMD128DigestTest.cs
@@ -1,135 +1,74 @@
 using System;
-using System.Text;
 
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
-     * RipeMD128 IDigest Test
-     */
-    [TestFixture]
-    public class RipeMD128DigestTest: ITest
-    {
-        readonly static string[] messages =
-        {
-            "",
-            "a",
-            "abc",
-            "message digest",
-            "abcdefghijklmnopqrstuvwxyz",
-            "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
-            "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-        };
-
-        readonly static string[] digests = {
-            "cdf26213a150dc3ecb610f18f6b38b46",
-            "86be7afa339d0fc7cfc785e72f578d33",
-            "c14a12199c66e4ba84636b0f69144c77",
-            "9e327b3d6e523062afc1132d7df9d1b8",
-            "fd2aa607f71dc8f510714922b371834e",
-            "a1aa0689d0fafa2ddc22e88b49133a06",
-            "d1e959eb179c911faea4624c60c5c702",
-            "3f45ef194732c2dbb2c4a2c769795fa3"
-        };
-
-		readonly static string MillionADigest = "4a7f5723f954eba1216c9d8f6320431f";
-
-        public string Name
-        {
-			get { return "RipeMD128"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new RipeMD128Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-
-            for (int i = 0; i < messages.Length; i++)
-            {
-                byte[] m = Encoding.ASCII.GetBytes(messages[i]);
-                digest.BlockUpdate(m, 0, m.Length);
-                digest.DoFinal(resBuf, 0);
-
-                if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i])))
-                {
-                    return new SimpleTestResult(false, Name + ": Vector " + i + " failed");
-                }
-            }
-
-            //
-            // test 2
-            //
-            byte[] mm = Encoding.ASCII.GetBytes(messages[messages.Length-1]);
-
-            digest.BlockUpdate(mm, 0, mm.Length/2);
-
-            // clone the IDigest
-            IDigest d = new RipeMD128Digest((RipeMD128Digest)digest);
-
-            digest.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "RipeMD128 failing clone test"
-                    + SimpleTest.NewLine
-                    + "    expected: " + digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            d.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "RipeMD128 failing clone test - part 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " +  digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            for (int i = 0; i < 1000000; i++)
-            {
-                digest.Update((byte)'a');
-            }
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(MillionADigest)))
-            {
-                return new SimpleTestResult(false, Name + ": Million a's failed");
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
+	/**
+	 * RIPEMD128 Digest Test
+	 */
+	[TestFixture]
+	public class RipeMD128DigestTest
+		: DigestTest
+	{
+		readonly static string[] messages = {
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		readonly static string[] digests = {
+			"cdf26213a150dc3ecb610f18f6b38b46",
+			"86be7afa339d0fc7cfc785e72f578d33",
+			"c14a12199c66e4ba84636b0f69144c77",
+			"9e327b3d6e523062afc1132d7df9d1b8",
+			"fd2aa607f71dc8f510714922b371834e",
+			"a1aa0689d0fafa2ddc22e88b49133a06",
+			"d1e959eb179c911faea4624c60c5c702",
+			"3f45ef194732c2dbb2c4a2c769795fa3"
+		};
+
+		readonly static String million_a_digest = "4a7f5723f954eba1216c9d8f6320431f";
+
+		internal RipeMD128DigestTest()
+			: base(new RipeMD128Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new RipeMD128Digest((RipeMD128Digest)digest);
+		}
+
+		public static void Main(
 			string[] args)
-        {
-            ITest test = new RipeMD128DigestTest();
-            ITestResult result = test.Perform();
-
-            Console.WriteLine(result);
-        }
+		{
+			RunTest(new RipeMD128DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
-
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/RipeMD160DigestTest.cs b/crypto/test/src/crypto/test/RipeMD160DigestTest.cs
index 347c64d49..76f472574 100644
--- a/crypto/test/src/crypto/test/RipeMD160DigestTest.cs
+++ b/crypto/test/src/crypto/test/RipeMD160DigestTest.cs
@@ -1,135 +1,74 @@
 using System;
-using System.Text;
 
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
-     * RipeMD160 IDigest Test
-     */
-    [TestFixture]
-    public class RipeMD160DigestTest
-		: ITest
-    {
-        readonly static string[] messages =
-        {
-            "",
-            "a",
-            "abc",
-            "message digest",
-            "abcdefghijklmnopqrstuvwxyz",
-            "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
-            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
-            "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-        };
-
-        readonly static string[] digests = {
-            "9c1185a5c5e9fc54612808977ee8f548b2258d31",
-            "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
-            "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
-            "5d0689ef49d2fae572b881b123a85ffa21595f36",
-            "f71c27109c692c1b56bbdceb5b9d2865b3708dbc",
-            "12a053384a9c0c88e405a06c27dcf49ada62eb2b",
-            "b0e20b6e3116640286ed3a87a5713079b21f5189",
-            "9b752e45573d4b39f4dbd3323cab82bf63326bfb"
-        };
-
-        readonly static string MillionADigest = "52783243c1697bdbe16d37f97f68f08325dc1528";
-
-        public string Name
-        {
-			get { return "RipeMD160"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new RipeMD160Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-
-            for (int i = 0; i < messages.Length; i++)
-            {
-                byte[] m = Encoding.ASCII.GetBytes(messages[i]);
-                digest.BlockUpdate(m, 0, m.Length);
-                digest.DoFinal(resBuf, 0);
-
-                if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i])))
-                {
-                    return new SimpleTestResult(false, Name + ": Vector " + i + " failed");
-                }
-            }
-
-            //
-            // test 2
-            //
-            byte[] mm = Encoding.ASCII.GetBytes(messages[messages.Length-1]);
-
-            digest.BlockUpdate(mm, 0, mm.Length/2);
-
-            // clone the IDigest
-            IDigest d = new RipeMD160Digest((RipeMD160Digest)digest);
-
-            digest.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "RipeMD160 failing clone test"
-                    + SimpleTest.NewLine
-                    + "    expected: " + digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            d.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "RipeMD160 failing clone test - part 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " +  digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            for (int i = 0; i < 1000000; i++)
-            {
-                digest.Update((byte)'a');
-            }
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(MillionADigest)))
-            {
-                return new SimpleTestResult(false, Name + ": Million a's failed");
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
+	/**
+	 * RIPEMD160 Digest Test
+	 */
+	[TestFixture]
+	public class RipeMD160DigestTest
+		: DigestTest
+	{
+		readonly static string[] messages = {
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		readonly static string[] digests = {
+			"9c1185a5c5e9fc54612808977ee8f548b2258d31",
+			"0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
+			"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
+			"5d0689ef49d2fae572b881b123a85ffa21595f36",
+			"f71c27109c692c1b56bbdceb5b9d2865b3708dbc",
+			"12a053384a9c0c88e405a06c27dcf49ada62eb2b",
+			"b0e20b6e3116640286ed3a87a5713079b21f5189",
+			"9b752e45573d4b39f4dbd3323cab82bf63326bfb"
+		};
+
+		readonly static string million_a_digest = "52783243c1697bdbe16d37f97f68f08325dc1528";
+
+		internal RipeMD160DigestTest()
+			: base(new RipeMD160Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new RipeMD160Digest((RipeMD160Digest)digest);
+		}
 
 		public static void Main(
 			string[] args)
-        {
-            ITest test = new RipeMD160DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+		{
+			RunTest(new RipeMD160DigestTest());
+		}
 
-        [Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
 			Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/RipeMD256DigestTest.cs b/crypto/test/src/crypto/test/RipeMD256DigestTest.cs
index 909200d64..27a9c88cc 100644
--- a/crypto/test/src/crypto/test/RipeMD256DigestTest.cs
+++ b/crypto/test/src/crypto/test/RipeMD256DigestTest.cs
@@ -1,97 +1,67 @@
 using System;
-using System.Text;
 
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /// <summary> RipeMD256 IDigest Test</summary>
-    [TestFixture]
-    public class RipeMD256DigestTest
-		: ITest
-    {
-        public string Name
-        {
-			get { return "RipeMD256"; }
-        }
-
-		internal static readonly string[] messages = new string[]{"", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
-
-		internal static readonly string[] digests = new string[]{"02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d", "f9333e45d857f5d90a91bab70a1eba0cfb1be4b0783c9acfcd883a9134692925", "afbd6e228b9d8cbbcef5ca2d03e6dba10ac0bc7dcbe4680e1e42d2e975459b65", "87e971759a1ce47a514d5c914c392c9018c7c46bc14465554afcdf54a5070c0e", "649d3034751ea216776bf9a18acc81bc7896118a5197968782dd1fd97d8d5133", "3843045583aac6c8c8d9128573e7a9809afb2a0f34ccc36ea9e72f16f6368e3f", "5740a408ac16b720b84424ae931cbb1fe363d1d0bf4017f1a89f7ea6de77a0b8", "06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd"};
-
-		internal const string MillionADigest = "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978";
-
-		public virtual ITestResult Perform()
-        {
-            IDigest digest = new RipeMD256Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-
-			for (int i = 0; i < messages.Length; i++)
-            {
-                byte[] m = Encoding.ASCII.GetBytes(messages[i]);
-                digest.BlockUpdate(m, 0, m.Length);
-                digest.DoFinal(resBuf, 0);
-
-                if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i])))
-                {
-                    return new SimpleTestResult(false, Name + ": Vector " + i + " failed" + "    expected: " + digests[i] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-                }
-            }
-
-            //
-            // test 2
-            //
-            byte[] m2 = Encoding.ASCII.GetBytes(messages[messages.Length - 1]);
-            digest.BlockUpdate(m2, 0, m2.Length / 2);
-
-			// clone the IDigest
-            IDigest d = new RipeMD256Digest((RipeMD256Digest) digest);
-
-            digest.BlockUpdate(m2, m2.Length / 2, m2.Length - m2.Length / 2);
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length - 1])))
-            {
-                return new SimpleTestResult(false, "RipeMD256 failing clone test" + SimpleTest.NewLine + "    expected: " + digests[digests.Length - 1] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            d.BlockUpdate(m2, m2.Length / 2, m2.Length - m2.Length / 2);
-            d.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length - 1])))
-            {
-                return new SimpleTestResult(false, "RipeMD256 failing clone test - part 2" + SimpleTest.NewLine + "    expected: " + digests[digests.Length - 1] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            for (int i = 0; i < 1000000; i++)
-            {
-                digest.Update((byte) 'a');
-            }
+	/**
+	 * RIPEMD256 Digest Test
+	 */
+	[TestFixture]
+	public class RipeMD256DigestTest
+		: DigestTest
+	{
+		readonly static string[] messages = {
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		readonly static string[] digests = {
+			"02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d",
+			"f9333e45d857f5d90a91bab70a1eba0cfb1be4b0783c9acfcd883a9134692925",
+			"afbd6e228b9d8cbbcef5ca2d03e6dba10ac0bc7dcbe4680e1e42d2e975459b65",
+			"87e971759a1ce47a514d5c914c392c9018c7c46bc14465554afcdf54a5070c0e",
+			"649d3034751ea216776bf9a18acc81bc7896118a5197968782dd1fd97d8d5133",
+			"3843045583aac6c8c8d9128573e7a9809afb2a0f34ccc36ea9e72f16f6368e3f",
+			"5740a408ac16b720b84424ae931cbb1fe363d1d0bf4017f1a89f7ea6de77a0b8",
+			"06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd"
+		};
+
+		readonly static string million_a_digest = "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978";
+
+		internal RipeMD256DigestTest()
+			: base(new RipeMD256Digest(), messages, digests)
+		{
+		}
 
-			digest.DoFinal(resBuf, 0);
+		public override void PerformTest()
+		{
+			base.PerformTest();
 
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(MillionADigest)))
-            {
-                return new SimpleTestResult(false, Name + ": Million a's failed");
-            }
+			millionATest(million_a_digest);
+		}
 
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new RipeMD256Digest((RipeMD256Digest)digest);
+		}
 
 		public static void Main(
 			string[] args)
-        {
-            ITest test = new RipeMD256DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+		{
+			RunTest(new RipeMD256DigestTest());
+		}
 
 		[Test]
 		public void TestFunction()
@@ -100,5 +70,5 @@ namespace Org.BouncyCastle.Crypto.Tests
 
 			Assert.AreEqual(Name + ": Okay", resultText);
 		}
-    }
+	}
 }
diff --git a/crypto/test/src/crypto/test/RipeMD320DigestTest.cs b/crypto/test/src/crypto/test/RipeMD320DigestTest.cs
index 253cb9d9a..51296e55b 100644
--- a/crypto/test/src/crypto/test/RipeMD320DigestTest.cs
+++ b/crypto/test/src/crypto/test/RipeMD320DigestTest.cs
@@ -1,105 +1,74 @@
 using System;
-using System.Text;
 
 using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /// <summary> RipeMD320 IDigest Test</summary>
-    [TestFixture]
-    public class RipeMD320DigestTest
-		: ITest
-    {
-        public string Name
-        {
-			get { return "RipeMD320"; }
-        }
-
-		internal static readonly string[] messages = new string[]{"", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
-
-		internal static readonly string[] digests = new string[]{"22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8", "ce78850638f92658a5a585097579926dda667a5716562cfcf6fbe77f63542f99b04705d6970dff5d", "de4c01b3054f8930a79d09ae738e92301e5a17085beffdc1b8d116713e74f82fa942d64cdbc4682d", "3a8e28502ed45d422f68844f9dd316e7b98533fa3f2a91d29f84d425c88d6b4eff727df66a7c0197", "cabdb1810b92470a2093aa6bce05952c28348cf43ff60841975166bb40ed234004b8824463e6b009", "d034a7950cf722021ba4b84df769a5de2060e259df4c9bb4a4268c0e935bbc7470a969c9d072a1ac", "ed544940c86d67f250d232c30b7b3e5770e0c60c8cb9a4cafe3b11388af9920e1b99230b843c86a4", "557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42"};
-
-		internal const string MillionADigest = "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66";
-
-		public virtual ITestResult Perform()
-        {
-            IDigest digest = new RipeMD320Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-
-            for (int i = 0; i < messages.Length; i++)
-            {
-                byte[] m = Encoding.ASCII.GetBytes(messages[i]);
-                digest.BlockUpdate(m, 0, m.Length);
-                digest.DoFinal(resBuf, 0);
-
-                if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i])))
-                {
-                    Console.WriteLine(Name + ": Vector " + i + " failed" + "    expected: " + digests[i] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-                    return new SimpleTestResult(false, Name + ": Vector " + i + " failed");
-                }
-            }
-
-            //
-            // test 2
-            //
-            byte[] m2 = Encoding.ASCII.GetBytes(messages[messages.Length - 1]);
-
-            digest.BlockUpdate(m2, 0, m2.Length / 2);
-
-            // clone the IDigest
-            IDigest d = new RipeMD320Digest((RipeMD320Digest) digest);
-
-            digest.BlockUpdate(m2, m2.Length / 2, m2.Length - m2.Length / 2);
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length - 1])))
-            {
-                return new SimpleTestResult(false, "RipeMD320 failing clone test" + SimpleTest.NewLine + "    expected: " + digests[digests.Length - 1] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            d.BlockUpdate(m2, m2.Length / 2, m2.Length - m2.Length / 2);
-            d.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length - 1])))
-            {
-                return new SimpleTestResult(false, "RipeMD320 failing clone test - part 2" + SimpleTest.NewLine + "    expected: " + digests[digests.Length - 1] + SimpleTest.NewLine + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            for (int i = 0; i < 1000000; i++)
-            {
-                digest.Update((byte) 'a');
-            }
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(MillionADigest)))
-            {
-                return new SimpleTestResult(false, Name + ": Million a's failed");
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
+	/**
+	 * RIPEMD320 Digest Test
+	 */
+	[TestFixture]
+	public class RipeMD320DigestTest
+		: DigestTest
+	{
+		readonly static string[] messages = {
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+		};
+
+		readonly static string[] digests = {
+			"22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8",
+			"ce78850638f92658a5a585097579926dda667a5716562cfcf6fbe77f63542f99b04705d6970dff5d",
+			"de4c01b3054f8930a79d09ae738e92301e5a17085beffdc1b8d116713e74f82fa942d64cdbc4682d",
+			"3a8e28502ed45d422f68844f9dd316e7b98533fa3f2a91d29f84d425c88d6b4eff727df66a7c0197",
+			"cabdb1810b92470a2093aa6bce05952c28348cf43ff60841975166bb40ed234004b8824463e6b009",
+			"d034a7950cf722021ba4b84df769a5de2060e259df4c9bb4a4268c0e935bbc7470a969c9d072a1ac",
+			"ed544940c86d67f250d232c30b7b3e5770e0c60c8cb9a4cafe3b11388af9920e1b99230b843c86a4",
+			"557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42"
+		};
+
+		readonly static string million_a_digest = "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66";
+
+		internal RipeMD320DigestTest()
+			: base(new RipeMD320Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new RipeMD320Digest((RipeMD320Digest)digest);
+		}
+
+		public static void Main(
 			string[] args)
-        {
-            ITest test = new RipeMD320DigestTest();
-            ITestResult result = test.Perform();
-
-            Console.WriteLine(result);
-        }
+		{
+			RunTest(new RipeMD320DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/SHA1DigestTest.cs b/crypto/test/src/crypto/test/SHA1DigestTest.cs
index 22a5c8f46..8e0564dd8 100644
--- a/crypto/test/src/crypto/test/SHA1DigestTest.cs
+++ b/crypto/test/src/crypto/test/SHA1DigestTest.cs
@@ -12,126 +12,32 @@ namespace Org.BouncyCastle.Crypto.Tests
 	/// <remarks>Standard vector test for SHA-1 from "Handbook of Applied Cryptography", page 345.</remarks>
 	[TestFixture]
 	public class Sha1DigestTest
-		: SimpleTest
+		: DigestTest
 	{
-		//static private string testVec1 = "";
-		static private string resVec1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
-
-		static private string testVec2 = "61";
-		static private string resVec2 = "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8";
-
-		static private string testVec3 = "616263";
-		static private string resVec3 = "a9993e364706816aba3e25717850c26c9cd0d89d";
-
-		static private string testVec4 = "6162636465666768696a6b6c6d6e6f707172737475767778797a";
-		static private string resVec4 = "32d10c7b8cf96570ca04ce37f2a19d84240d3a89";
+		private static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdefghijklmnopqrstuvwxyz"
+		};
 
-		public override string Name
+		private static string[] digests =
+		{
+			"da39a3ee5e6b4b0d3255bfef95601890afd80709",
+			"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8",
+			"a9993e364706816aba3e25717850c26c9cd0d89d",
+			"32d10c7b8cf96570ca04ce37f2a19d84240d3a89"
+		};
+
+		internal Sha1DigestTest()
+			: base(new Sha1Digest(), messages, digests)
 		{
-			get { return "SHA1"; }
 		}
 
-		public override void PerformTest()
+		protected override IDigest CloneDigest(IDigest digest)
 		{
-			IDigest digest = new Sha1Digest();
-			byte[] resBuf = new byte[digest.GetDigestSize()];
-			string resStr;
-
-			//
-			// test 1
-			//
-			digest.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec1.Equals(resStr))
-			{
-				Fail("failing standard vector test 1" + SimpleTest.NewLine
-					+ "    expected: " + resVec1 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
-
-			//
-			// test 2
-			//
-			byte[] bytes = Hex.Decode(testVec2);
-
-			digest.BlockUpdate(bytes, 0, bytes.Length);
-
-			digest.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec2.Equals(resStr))
-			{
-				Fail("failing standard vector test 2" + SimpleTest.NewLine
-					+ "    expected: " + resVec2 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
-
-			//
-			// test 3
-			//
-			bytes = Hex.Decode(testVec3);
-
-			digest.BlockUpdate(bytes, 0, bytes.Length);
-
-			digest.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec3.Equals(resStr))
-			{
-				Fail("failing standard vector test 3" + SimpleTest.NewLine
-					+ "    expected: " + resVec3 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
-
-			//
-			// test 4
-			//
-			bytes = Hex.Decode(testVec4);
-
-			digest.BlockUpdate(bytes, 0, bytes.Length);
-
-			digest.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec4.Equals(resStr))
-			{
-				Fail("failing standard vector test 4" + SimpleTest.NewLine
-					+ "    expected: " + resVec4 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
-
-			//
-			// test 5
-			//
-			bytes = Hex.Decode(testVec4);
-
-			digest.BlockUpdate(bytes, 0, bytes.Length / 2);
-
-			// clone the IDigest
-			IDigest d = new Sha1Digest((Sha1Digest)digest);
-
-			digest.BlockUpdate(bytes, bytes.Length / 2, bytes.Length - bytes.Length / 2);
-			digest.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec4.Equals(resStr))
-			{
-				Fail("failing standard vector test 5" + SimpleTest.NewLine
-					+ "    expected: " + resVec4 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
-
-			d.BlockUpdate(bytes, bytes.Length / 2, bytes.Length - bytes.Length / 2);
-			d.DoFinal(resBuf, 0);
-
-			resStr = Hex.ToHexString(resBuf);
-			if (!resVec4.Equals(resStr))
-			{
-				Fail("failing standard vector test 5" + SimpleTest.NewLine
-					+ "    expected: " + resVec4 + SimpleTest.NewLine
-					+ "    got     : " + resStr);
-			}
+			return new Sha1Digest((Sha1Digest)digest);
 		}
 
 		public static void Main(
diff --git a/crypto/test/src/crypto/test/SHA224DigestTest.cs b/crypto/test/src/crypto/test/SHA224DigestTest.cs
index 37035c30f..8207a18c7 100644
--- a/crypto/test/src/crypto/test/SHA224DigestTest.cs
+++ b/crypto/test/src/crypto/test/SHA224DigestTest.cs
@@ -9,192 +9,62 @@ using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
-     * standard vector test for SHA-224 from RFC 3874 - only the last three are in
-     * the RFC.
-     */
-    [TestFixture]
-    public class Sha224DigestTest
-        : ITest
-    {
-        private const string testVec1 = "";
-        private const string resVec1 = "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f";
-
-		private const string testVec2 = "61";
-        private const string resVec2 = "abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5";
-
-		private const string testVec3 = "616263";
-        private const string resVec3 = "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7";
-
-		private const string testVec4 = "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071";
-        private const string resVec4 = "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525";
+	/**
+	 * standard vector test for SHA-224 from RFC 3874 - only the last three are in
+	 * the RFC.
+	 */
+	[TestFixture]
+	public class Sha224DigestTest
+		: DigestTest
+	{
+		private static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+		};
+
+		private static string[] digests =
+		{
+			"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
+			"abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5",
+			"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7",
+			"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525"
+		};
 
 		// 1 million 'a'
-        private const string testVec5 = "61616161616161616161";
-        private const string resVec5 = "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67";
-
-		public string Name
-        {
-			get { return "SHA224"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new Sha224Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-			//
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[]  bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length/2);
-
-            // clone the IDigest
-            IDigest d = new Sha224Digest((Sha224Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
+		private static string million_a_digest = "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67";
 
-            // test 6
-            bytes = Hex.Decode(testVec5);
-            for ( int i = 0; i < 100000; i++ )
-            {
-                digest.BlockUpdate(bytes, 0, bytes.Length);
-            }
-            digest.DoFinal(resBuf, 0);
+		internal Sha224DigestTest()
+			: base(new Sha224Digest(), messages, digests)
+		{
+		}
 
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec5.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-224 failing standard vector test 6"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec5
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
+		public override void PerformTest()
+		{
+			base.PerformTest();
 
-			return new SimpleTestResult(true, Name + ": Okay");
-        }
+			millionATest(million_a_digest);
+		}
 
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new Sha224DigestTest();
-            ITestResult result = test.Perform();
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new Sha224Digest((Sha224Digest)digest);
+		}
 
-			Console.WriteLine(result);
-        }
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Sha224DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
 			Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/SHA256DigestTest.cs b/crypto/test/src/crypto/test/SHA256DigestTest.cs
index 67f0c2397..d4d29ccbb 100644
--- a/crypto/test/src/crypto/test/SHA256DigestTest.cs
+++ b/crypto/test/src/crypto/test/SHA256DigestTest.cs
@@ -4,202 +4,68 @@ using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Engines;
-using Org.BouncyCastle.Crypto.Encodings;
-using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
+	/**
      * standard vector test for SHA-256 from FIPS Draft 180-2.
      *
      * Note, the first two vectors are _not_ from the draft, the last three are.
      */
-    [TestFixture]
-    public class Sha256DigestTest
-		: ITest
-    {
-//        static private string  testVec1 = "";
-        static private string resVec1 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
-
-        static private string testVec2 = "61";
-        static private string resVec2 = "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb";
-
-        static private string testVec3 = "616263";
-        static private string resVec3 = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
-
-        static private string testVec4 = "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071";
-        static private string resVec4 = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1";
-
-        // 1 million 'a'
-        static private string testVec5 = "61616161616161616161";
-        static private string resVec5 = "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0";
-
-		public string Name
-        {
-			get { return "SHA256"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new Sha256Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-			//
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[]  bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length/2);
-
-            // clone the IDigest
-            IDigest d = new Sha256Digest((Sha256Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            // test 6
-            bytes = Hex.Decode(testVec5);
-            for ( int i = 0; i < 100000; i++ )
-            {
-                digest.BlockUpdate(bytes, 0, bytes.Length);
-            }
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec5.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-256 failing standard vector test 6"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec5
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
+	[TestFixture]
+	public class Sha256DigestTest
+		: DigestTest
+	{
+		private static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+		};
+
+		private static string[] digests =
+		{
+			"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+			"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
+			"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
+			"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
+		};
+
+		// 1 million 'a'
+		static private string  million_a_digest = "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0";
+
+		internal Sha256DigestTest()
+			: base(new Sha256Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new Sha256Digest((Sha256Digest)digest);
+		}
 
 		public static void Main(
 			string[] args)
-        {
-            ITest test = new Sha256DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+		{
+			RunTest(new Sha256DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
-
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/SHA384DigestTest.cs b/crypto/test/src/crypto/test/SHA384DigestTest.cs
index 70c26edcc..ae9ad0c17 100644
--- a/crypto/test/src/crypto/test/SHA384DigestTest.cs
+++ b/crypto/test/src/crypto/test/SHA384DigestTest.cs
@@ -4,200 +4,67 @@ using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Engines;
-using Org.BouncyCastle.Crypto.Encodings;
-using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /**
+	/**
      * standard vector test for SHA-384 from FIPS Draft 180-2.
      *
      * Note, the first two vectors are _not_ from the draft, the last three are.
      */
-    [TestFixture]
-    public class Sha384DigestTest
-		: ITest
-    {
-//        static private string testVec1 = "";
-        static private string resVec1 = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b";
-
-        static private string testVec2 = "61";
-        static private string resVec2 = "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31";
-
-        static private string testVec3 = "616263";
-        static private string resVec3 = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7";
-
-        static private string testVec4 = "61626364656667686263646566676869636465666768696a6465666768696a6b65666768696a6b6c666768696a6b6c6d6768696a6b6c6d6e68696a6b6c6d6e6f696a6b6c6d6e6f706a6b6c6d6e6f70716b6c6d6e6f7071726c6d6e6f707172736d6e6f70717273746e6f707172737475";
-        static private string resVec4 = "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039";
-
-        // 1 million 'a'
-        static private string testVec5 = "61616161616161616161";
-        static private string resVec5 = "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985";
-
-		public string Name
-        {
-			get { return "SHA384"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new Sha384Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-			//
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 1"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec1
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[] bytes = Hex.Decode(testVec2);
-			digest.BlockUpdate(bytes, 0, bytes.Length);
-
-			digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec2
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-			//
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 3"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec3
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 4"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length/2);
-
-            // clone the IDigest
-            IDigest d = new Sha384Digest((Sha384Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length/2, bytes.Length - bytes.Length/2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 5"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec4
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            // test 6
-            bytes = Hex.Decode(testVec5);
-            for ( int i = 0; i < 100000; i++ )
-            {
-                digest.BlockUpdate(bytes, 0, bytes.Length);
-            }
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec5.Equals(resStr))
-            {
-                return new SimpleTestResult(false,
-                    "SHA-384 failing standard vector test 6"
-                    + SimpleTest.NewLine
-                    + "    expected: " + resVec5
-                    + SimpleTest.NewLine
-                    + "    got     : " + resStr);
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new Sha384DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+	[TestFixture]
+	public class Sha384DigestTest
+		: DigestTest
+	{
+		private static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+		};
+
+		private static string[] digests =
+		{
+			"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b",
+			"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31",
+			"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7",
+			"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"
+		};
+
+		static private string  million_a_digest = "9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985";
+
+		internal Sha384DigestTest()
+			: base(new Sha384Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new Sha384Digest((Sha384Digest)digest);
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Sha384DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
 			Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/SHA512DigestTest.cs b/crypto/test/src/crypto/test/SHA512DigestTest.cs
index c8096b7db..814500b63 100644
--- a/crypto/test/src/crypto/test/SHA512DigestTest.cs
+++ b/crypto/test/src/crypto/test/SHA512DigestTest.cs
@@ -9,157 +9,62 @@ using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
-    /// <summary>
-    /// Standard vector test for SHA-512 from FIPS Draft 180-2.
-    /// Note, the first two vectors are _not_ from the draft, the last three are.
-    /// </summary>
-    [TestFixture]
-    public class Sha512DigestTest
-		: ITest
-    {
-        public string Name
-        {
-			get { return "SHA512"; }
-        }
-
-		//private static string testVec1 = "";
-        private static string resVec1 = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e";
-
-        private static string testVec2 = "61";
-        private static string resVec2 = "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75";
-
-        private static string testVec3 = "616263";
-        private static string resVec3 = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f";
-
-        private static string testVec4 = "61626364656667686263646566676869636465666768696a6465666768696a6b65666768696a6b6c666768696a6b6c6d6768696a6b6c6d6e68696a6b6c6d6e6f696a6b6c6d6e6f706a6b6c6d6e6f70716b6c6d6e6f7071726c6d6e6f707172736d6e6f70717273746e6f707172737475";
-        private static string resVec4 = "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909";
-
-        // 1 million 'a'
-        private static string testVec5 = "61616161616161616161";
-        private static string resVec5 = "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b";
-
-        public virtual ITestResult Perform()
-        {
-            IDigest digest = new Sha512Digest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-            string resStr;
-
-            //
-            // test 1
-            //
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec1.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 1" + SimpleTest.NewLine + "    expected: " + resVec1 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            //
-            // test 2
-            //
-            byte[] bytes = Hex.Decode(testVec2);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec2.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 2" + SimpleTest.NewLine + "    expected: " + resVec2 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            //
-            // test 3
-            //
-            bytes = Hex.Decode(testVec3);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec3.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 3" + SimpleTest.NewLine + "    expected: " + resVec3 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            //
-            // test 4
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length);
-
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 4" + SimpleTest.NewLine + "    expected: " + resVec4 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            //
-            // test 5
-            //
-            bytes = Hex.Decode(testVec4);
-
-            digest.BlockUpdate(bytes, 0, bytes.Length / 2);
-
-            // clone the IDigest
-            IDigest d = new Sha512Digest((Sha512Digest)digest);
-
-            digest.BlockUpdate(bytes, bytes.Length / 2, bytes.Length - bytes.Length / 2);
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 5" + SimpleTest.NewLine + "    expected: " + resVec4 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            d.BlockUpdate(bytes, bytes.Length / 2, bytes.Length - bytes.Length / 2);
-            d.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec4.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 5" + SimpleTest.NewLine + "    expected: " + resVec4 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            // test 6
-            bytes = Hex.Decode(testVec5);
-            for (int i = 0; i < 100000; i++)
-            {
-                digest.BlockUpdate(bytes, 0, bytes.Length);
-            }
-            digest.DoFinal(resBuf, 0);
-
-            resStr = Hex.ToHexString(resBuf);
-            if (!resVec5.Equals(resStr))
-            {
-                return new SimpleTestResult(false, "SHA-512 failing standard vector test 6" + SimpleTest.NewLine + "    expected: " + resVec5 + SimpleTest.NewLine + "    got     : " + resStr);
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new Sha512DigestTest();
-            ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
-        }
+	/// <summary>
+	/// Standard vector test for SHA-512 from FIPS Draft 180-2.
+	/// Note, the first two vectors are _not_ from the draft, the last three are.
+	/// </summary>
+	[TestFixture]
+	public class Sha512DigestTest
+		: DigestTest
+	{
+		private static string[] messages =
+		{
+			"",
+			"a",
+			"abc",
+			"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+		};
+
+		private static string[] digests =
+		{
+			"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
+			"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75",
+			"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f",
+			"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"   
+		};
+
+		// 1 million 'a'
+		static private string  million_a_digest = "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b";
+
+		internal Sha512DigestTest()
+			: base(new Sha512Digest(), messages, digests)
+		{
+		}
+
+		public override void PerformTest()
+		{
+			base.PerformTest();
+
+			millionATest(million_a_digest);
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new Sha512Digest((Sha512Digest)digest);
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Sha512DigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
 			Assert.AreEqual(Name + ": Okay", resultText);
-        }
-    }
+		}
+	}
 }
diff --git a/crypto/test/src/crypto/test/SkeinDigestTest.cs b/crypto/test/src/crypto/test/SkeinDigestTest.cs
new file mode 100644
index 000000000..b6f1c542b
--- /dev/null
+++ b/crypto/test/src/crypto/test/SkeinDigestTest.cs
@@ -0,0 +1,303 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Digests;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+
+	[TestFixture]
+	public class SkeinDigestTest
+		: SimpleTest
+	{
+		private class Case
+		{
+			private byte[] message;
+			private byte[] digest;
+			private int blockSize;
+			private int outputSize;
+
+			public Case(int blockSize, int outputSize, string message, string digest)
+			{
+				this.blockSize = blockSize;
+				this.outputSize = outputSize;
+				this.message = Hex.Decode(message);
+				this.digest = Hex.Decode(digest);
+			}
+
+			public int getOutputSize()
+			{
+				return outputSize;
+			}
+
+			public int getBlockSize()
+			{
+				return blockSize;
+			}
+
+			public byte[] getMessage()
+			{
+				return message;
+			}
+
+			public byte[] getDigest()
+			{
+				return digest;
+			}
+
+		}
+
+		// Test cases from skein_golden_kat.txt and skein_golden_kat_short.txt in Skein 1.3 NIST CD
+		private static readonly Case[] TEST_CASES = {
+			new Case(256, 256, "", "c8877087da56e072870daa843f176e9453115929094c3a40c463a196c29bf7ba"),
+			new Case(256, 256, "fb", "088eb23cc2bccfb8171aa64e966d4af937325167dfcd170700ffd21f8a4cbdac"),
+			new Case(256, 256, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8",
+			         "5c3002ff57a627089ea2f97a5000d5678416389019e80e45a3bbcab118315d26"),
+			new Case(256, 256, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a129233",
+			         "640c894a4bba6574c83e920ddf7dd2982fc634881bbbcb9d774eae0a285e89ce"),
+			new Case(256, 160, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "0cd491b7715704c3a15a45a1ca8d93f8f646d3a1"),
+			new Case(256, 224, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "afd1e2d0f5b6cd4e1f8b3935fa2497d27ee97e72060adac099543487"),
+			new Case(256, 256, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "4de6fe2bfdaa3717a4261030ef0e044ced9225d066354610842a24a3eafd1dcf"),
+			new Case(256, 384, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "954620fb31e8b782a2794c6542827026fe069d715df04261629fcbe81d7d529b"
+			         + "95ba021fa4239fb00afaa75f5fd8e78b"),
+			new Case(256, 512, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "51347e27c7eabba514959f899a6715ef6ad5cf01c23170590e6a8af399470bf9"
+			         + "0ea7409960a708c1dbaa90e86389df254abc763639bb8cdf7fb663b29d9557c3"),
+			new Case(256, 1024, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "6c9b6facbaf116b538aa655e0be0168084aa9f1be445f7e06714585e5999a6c9"
+			         + "84fffa9d41a316028692d4aad18f573fbf27cf78e84de26da1928382b023987d"
+			         + "cfe002b6201ea33713c54a8a5d9eb346f0365e04330d2faaf7bc8aba92a5d7fb"
+			         + "6345c6fb26750bce65ab2045c233627679ac6e9acb33602e26fe3526063ecc8b"),
+
+			new Case(512, 512, "", "bc5b4c50925519c290cc634277ae3d6257212395cba733bbad37a4af0fa06af4"
+			         + "1fca7903d06564fea7a2d3730dbdb80c1f85562dfcc070334ea4d1d9e72cba7a"),
+			new Case(512, 512, "fb", "c49e03d50b4b2cc46bd3b7ef7014c8a45b016399fd1714467b7596c86de98240"
+			         + "e35bf7f9772b7d65465cd4cffab14e6bc154c54fc67b8bc340abf08eff572b9e"),
+			new Case(512, 512, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8",
+			         "abefb179d52f68f86941acbbe014cc67ec66ad78b7ba9508eb1400ee2cbdb06f"
+			         + "9fe7c2a260a0272d0d80e8ef5e8737c0c6a5f1c02ceb00fb2746f664b85fcef5"),
+			new Case(512, 512, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a129233",
+			         "5c5b7956f9d973c0989aa40a71aa9c48a65af2757590e9a758343c7e23ea2df4"
+			         + "057ce0b49f9514987feff97f648e1dd065926e2c371a0211ca977c213f14149f"),
+			new Case(512, 160, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "ef03079d61b57c6047e15fa2b35b46fa24279539"),
+			new Case(512, 224, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "d9e3219b214e15246a2038f76a573e018ef69b385b3bd0576b558231"),
+			new Case(512, 256, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "809dd3f763a11af90912bbb92bc0d94361cbadab10142992000c88b4ceb88648"),
+			new Case(512, 384, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "825f5cbd5da8807a7b4d3e7bd9cd089ca3a256bcc064cd73a9355bf3ae67f2bf"
+			         + "93ac7074b3b19907a0665ba3a878b262"),
+			new Case(512, 512, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "1a0d5abf4432e7c612d658f8dcfa35b0d1ab68b8d6bd4dd115c23cc57b5c5bcd"
+			         + "de9bff0ece4208596e499f211bc07594d0cb6f3c12b0e110174b2a9b4b2cb6a9"),
+
+			new Case(1024, 1024, "", "0fff9563bb3279289227ac77d319b6fff8d7e9f09da1247b72a0a265cd6d2a62"
+			         + "645ad547ed8193db48cff847c06494a03f55666d3b47eb4c20456c9373c86297"
+			         + "d630d5578ebd34cb40991578f9f52b18003efa35d3da6553ff35db91b81ab890"
+			         + "bec1b189b7f52cb2a783ebb7d823d725b0b4a71f6824e88f68f982eefc6d19c6"),
+			new Case(1024, 1024, "fb", "6426bdc57b2771a6ef1b0dd39f8096a9a07554565743ac3de851d28258fcff22"
+			         + "9993e11c4e6bebc8b6ecb0ad1b140276081aa390ec3875960336119427827473"
+			         + "4770671b79f076771e2cfdaaf5adc9b10cbae43d8e6cd2b1c1f5d6c82dc96618"
+			         + "00ddc476f25865b8748253173187d81da971c027d91d32fb390301c2110d2db2"),
+			new Case(1024, 1024, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8",
+			         "140e93726ab0b0467c0b8a834ad8cda4d1769d273661902b70db0dcb5ee692ac"
+			         + "b3f852d03b11f857850f2428432811309c1dcbe5724f00267ea3667e89fadb4e"
+			         + "4911da6b0ba8a7eddf87c1c67152ef0f07b7fead3557318478bdef5ad1e5926d"
+			         + "7071fdd4bfa5076d4b3253f8de479ebdf5357676f1641b2f097e9b785e9e528e"),
+			new Case(1024, 1024, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a129233",
+			         "31105e1ef042c30b95b16e0f6e6a1a19172bb7d54a0597dd0c711194888efe1d"
+			         + "bce82d47416df9577ca387219f06e45cd10964ff36f6711edbbea0e9595b0f66"
+			         + "f72b755d70a46857e0aec98561a743d49370d8e572e212811273125f66cc30bf"
+			         + "117d3221894c48012bf6e2219de91e064b01523517420a1e00f71c4cc04bab62"),
+			new Case(1024, 160, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "2e6a4cbf2ef05ea9c24b93e8d1de732ddf2739eb"),
+			new Case(1024, 224, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "1d6de19f37f7a3c265440eecb4b9fbd3300bb5ac60895cfc0d4d3c72"),
+			new Case(1024, 256, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "986a4d472b123e8148731a8eac9db23325f0058c4ccbc44a5bb6fe3a8db672d7"),
+			new Case(1024, 384, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "9c3d0648c11f31c18395d5e6c8ebd73f43d189843fc45235e2c35e345e12d62b"
+			         + "c21a41f65896ddc6a04969654c2e2ce9"),
+			new Case(1024, 512, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "5d0416f49c2d08dfd40a1446169dc6a1d516e23b8b853be4933513051de8d5c2"
+			         + "6baccffb08d3b16516ba3c6ccf3e9a6c78fff6ef955f2dbc56e1459a7cdba9a5"),
+			new Case(1024, 1024, "fbd17c26b61a82e12e125f0d459b96c91ab4837dff22b39b78439430cdfc5dc8"
+			         + "78bb393a1a5f79bef30995a85a12923339ba8ab7d8fc6dc5fec6f4ed22c122bb"
+			         + "e7eb61981892966de5cef576f71fc7a80d14dab2d0c03940b95b9fb3a727c66a"
+			         + "6e1ff0dc311b9aa21a3054484802154c1826c2a27a0914152aeb76f1168d4410",
+			         "96ca81f586c825d0360aef5acaec49ad55289e1797072eee198b64f349ce65b6"
+			         + "e6ed804fe38f05135fe769cc56240ddda5098f620865ce4a4278c77fa2ec6bc3"
+			         + "1c0f354ca78c7ca81665bfcc5dc54258c3b8310ed421d9157f36c093814d9b25"
+			         + "103d83e0ddd89c52d0050e13a64c6140e6388431961685734b1f138fe2243086"),
+
+		};
+
+		public override string Name
+		{
+			get { return "SkeinDigest"; }
+		}
+
+		public override void PerformTest()
+		{
+			for (int i = 0; i < TEST_CASES.Length; i++)
+			{
+				Case test = TEST_CASES[i];
+				runTest(test);
+			}
+		}
+
+		private void runTest(Case dc)
+		{
+			SkeinDigest digest = new SkeinDigest(dc.getBlockSize(), dc.getOutputSize());
+
+			byte[] message = dc.getMessage();
+			digest.BlockUpdate(message, 0, message.Length);
+
+			byte[] output = new byte[digest.GetDigestSize()];
+			digest.DoFinal(output, 0);
+
+			if (!AreEqual(output, dc.getDigest()))
+			{
+				Fail(digest.AlgorithmName + " message mismatch.\n Message " + Hex.ToHexString(dc.getMessage()),
+				     Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			}
+
+			// Clone test
+			digest.BlockUpdate(message, 0, message.Length / 2);
+
+			// clone the Digest
+			IDigest d = new SkeinDigest(digest);
+
+			digest.BlockUpdate(message, message.Length / 2, message.Length - message.Length / 2);
+			digest.DoFinal(output, 0);
+
+			if (!AreEqual(dc.getDigest(), output))
+			{
+				Fail("failing clone vector test", Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			}
+
+			d.BlockUpdate(message, message.Length / 2, message.Length - message.Length / 2);
+			d.DoFinal(output, 0);
+
+			if (!AreEqual(dc.getDigest(), output))
+			{
+				Fail("failing second clone vector test", Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			}
+
+			//	        //
+			//	        // memo test
+			//	        //
+			//	        Memoable m = (Memoable)digest;
+			//
+			//	        digest.Update(message, 0, message.Length / 2);
+			//
+			//	        // copy the Digest
+			//	        Memoable copy1 = m.copy();
+			//	        Memoable copy2 = copy1.copy();
+			//
+			//	        digest.Update(message, message.Length / 2, message.Length - message.Length / 2);
+			//	        digest.DoFinal(output, 0);
+			//
+			//	        if (!AreEqual(dc.getDigest(), output))
+			//	        {
+			//				Fail("failing memo vector test", Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			//	        }
+			//
+			//	        m.reset(copy1);
+			//
+			//	        digest.Update(message, message.Length / 2, message.Length - message.Length / 2);
+			//	        digest.DoFinal(output, 0);
+			//
+			//	        if (!AreEqual(dc.getDigest(), output))
+			//	        {
+			//				fail("failing memo reset vector test", Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			//	        }
+			//
+			//	        IDigest md = (IDigest)copy2;
+			//
+			//	        md.Update(message, message.Length / 2, message.Length - message.Length / 2);
+			//	        md.DoFinal(output, 0);
+			//
+			//	        if (!AreEqual(dc.getDigest(), output))
+			//	        {
+			//				Fail("failing memo copy vector test", Hex.ToHexString(dc.getDigest()), Hex.ToHexString(output));
+			//	        }
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new SkeinDigestTest());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+
+	}
+}
\ No newline at end of file
diff --git a/crypto/test/src/crypto/test/SkeinMacTest.cs b/crypto/test/src/crypto/test/SkeinMacTest.cs
new file mode 100644
index 000000000..852c3b2c7
--- /dev/null
+++ b/crypto/test/src/crypto/test/SkeinMacTest.cs
@@ -0,0 +1,174 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Macs;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+
+	[TestFixture]
+	public class SkeinMacTest
+		: SimpleTest
+	{
+		private class Case
+		{
+			private byte[] message;
+			private byte[] digest;
+			private byte[] key;
+			private int blockSize;
+			private int outputSize;
+
+			public Case(int blockSize, int outputSize, String message, String key, String digest)
+			{
+				this.blockSize = blockSize;
+				this.outputSize = outputSize;
+				this.message = Hex.Decode(message);
+				this.key = Hex.Decode(key);
+				this.digest = Hex.Decode(digest);
+			}
+
+			public int getOutputSize()
+			{
+				return outputSize;
+			}
+
+			public int getBlockSize()
+			{
+				return blockSize;
+			}
+
+			public byte[] getMessage()
+			{
+				return message;
+			}
+
+			public byte[] getKey()
+			{
+				return key;
+			}
+
+			public byte[] getDigest()
+			{
+				return digest;
+			}
+
+			public override string ToString()
+			{
+				return String.Format("new Case({0}, {1}, \"{2}\", \"{3}\", \"{4}\"),", blockSize, outputSize,
+				                     Hex.ToHexString(message), Hex.ToHexString(key), Hex.ToHexString(digest));
+			}
+
+		}
+
+		// Test cases from skein_golden_kat.txt in Skein 1.3 NIST CD
+		// Excludes empty '(none)' key 'random+MAC' tests, which are in effect digest 
+		private static readonly Case[] TEST_CASES = {
+			new Case(256, 256, "", "cb41f1706cde09651203c2d0efbaddf8", "886e4efefc15f06aa298963971d7a25398fffe5681c84db39bd00851f64ae29d"),
+			new Case(256, 256, "d3", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "979422a94e3afaa46664124d4e5e8b9422b1d8baf11c6ae6725992ac72a112ca"),
+			new Case(256, 256, "d3090c72", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "1d658372cbea2f9928493cc47599d6f4ad8ce33536bedfa20b739f07516519d5"),
+			new Case(256, 256, "d3090c72167517f7", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e92", "41ef6b0f0fad81c040284f3b1a91e9c44e4c26a6d7207f3aac4362856ef12aca"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "ca8208119b9e4e4057631ab31015cfd256f6763a0a34381633d97f640899b84f"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "9e9980fcc16ee082cf164a5147d0e0692aeffe3dcb8d620e2bb542091162e2e9"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc235", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "c353a316558ec34f8245dd2f9c2c4961fbc7decc3b69053c103e4b8aaaf20394"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdf", "cb41f1706cde09651203c2d0efbaddf8", "b1b8c18188e69a6ecae0b6018e6b638c6a91e6de6881e32a60858468c17b520d"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e92", "1dfd2515a412e78852cd81a7f2167711b4ca19b2891c2ea36ba94f8451944793"),
+			new Case(256, 224, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf8", "a097340709b443ed2c0a921f5dcefef3ead65c4f0bcd5f13da54d7ed"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "ac1b4fab6561c92d0c487e082daec53e0db4f505e08bf51cae4fd5375e37fc04"),
+			new Case(256, 384, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e92", "96e6cebb23573d0a70ce36a67aa05d2403148093f25c695e1254887cc97f9771d2518413af4286bf2a06b61a53f7fcec"),
+			new Case(256, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "0e95e597e71d6350f20b99c4179f54f43a4722705c06ba765a82cb0a314fe2fe87ef8090063b757e53182706ed18737dadc0da1e1c66518f08334052702c5ed7"),
+			new Case(256, 264, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf8", "064abd4896f460b1953f5a357e7f7c5256e29cdb62b8740d0b52295cfa2ef4c7a2"),
+			new Case(256, 520, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "edf220e43e048603bd16197d59b673b9974de5b8bcf7cb1558a4799f6fd3743eb5fb400cd6129afc0c60e7b741b7e5806f0e0b93eb8429fbc7efa222175a9c80fd"),
+			new Case(256, 1032, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e92", "f3f59fb07399c7b73aae02a8590883cb2fdfde75c55654e71846522301bde48d267169adcc559e038e8c2f28faa552b550d51874055384adea93c036c71a1f0af0c7bcc3bc923738d5307b9da7cb423d4e615c629c4aba71f70d4c9d1fa008176825e51bfa0203445a4083947ec19f6a0fbd082b5b970f2396fb67420639410447"),
+			new Case(256, 2056, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "80eb80d9b8836b32fa576fc84ba08edfbdfd6979123d61914e610a70a372b37f560a10909484f9f4a377c93e29ba681dfe522c41dc83b5ee0567e5370007c7bbe4df0b2b4a25e088f80d72fc30734cdcd76d817b42fbd44dca881019afb25306f19d4e91848778af306517d2072cef72caa327e877c5b6554f83cec3d00877131b47c4d3b557f5a13541c4d5080ee3ce7a658993d083efd0db3496a8752060c3c8552f44b290cabdcc867f691ad605836c08dbd59c9528d885b600b85fdfc8a9d0e636ac3ad8b4295bcb0169e78dc358e77eacc8c4b61bddfa9e5f32d2268a006cfe05c57150fe8e68cabd21cf6cf6035aa1fe4db36c922b765aad0b64e82a2c37"),
+			new Case(256, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed696e6c9db1e6abea026288954a9c2d5758d7c5db7c9e48aa3d21cae3d977a7c3926066aa393dbd538dd0c30da8916c8757f24c18488014668a2627163a37b261833dc2f8c3c56b1b2e0be21fd3fbdb507b2950b77a6cc02efb393e57419383a920767bca2c972107aa61384542d47cbfb82cfe5c415389d1b0a2d74e2c5da851", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "8f88de68f03cd2f396ccdd49c3a0f4ff15bcda7eb357da9753f6116b124de91d"),
+			new Case(512, 512, "", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "9bd43d2a2fcfa92becb9f69faab3936978f1b865b7e44338fc9c8f16aba949ba340291082834a1fc5aa81649e13d50cd98641a1d0883062bfe2c16d1faa7e3aa"),
+			new Case(512, 512, "d3", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "f0c0a10f031c8fc69cfabcd54154c318b5d6cd95d06b12cf20264402492211ee010d5cecc2dc37fd772afac0596b2bf71e6020ef2dee7c860628b6e643ed9ff6"),
+			new Case(512, 512, "d3090c72167517f7", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "0c1f1921253dd8e5c2d4c5f4099f851042d91147892705829161f5fc64d89785226eb6e187068493ee4c78a4b7c0f55a8cbbb1a5982c2daf638fc6a74b16b0d7"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "478d7b6c0cc6e35d9ebbdedf39128e5a36585db6222891692d1747d401de34ce3db6fcbab6c968b7f2620f4a844a2903b547775579993736d2493a75ff6752a1"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e59", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "13c170bac1de35e5fb843f65fabecf214a54a6e0458a4ff6ea5df91915468f4efcd371effa8965a9e82c5388d84730490dcf3976af157b8baf550655a5a6ab78"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc235", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "a947812529a72fd3b8967ec391b298bee891babc8487a1ec4ea3d88f6b2b5be09ac6a780f30f8e8c3bbb4f18bc302a28f3e87d170ba0f858a8fefe3487478cca"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdf", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "7690ba61f10e0bba312980b0212e6a9a51b0e9aadfde7ca535754a706e042335b29172aae29d8bad18efaf92d43e6406f3098e253f41f2931eda5911dc740352"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "d10e3ba81855ac087fbf5a3bc1f99b27d05f98ba22441138026225d34a418b93fd9e8dfaf5120757451adabe050d0eb59d271b0fe1bbf04badbcf9ba25a8791b"),
+			new Case(512, 160, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "5670b226156570dff3efe16661ab86eb24982cdf"),
+			new Case(512, 224, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "c41b9ff9753e6c0f8ed88866e320535e927fe4da552c289841a920db"),
+			new Case(512, 384, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "dfbf5c1319a1d9d70efb2f1600fbcf694f935907f31d24a16d6cd2fb2d7855a769681766c0a29da778eed346cd1d740f"),
+			new Case(512, 512, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "04d8cddb0ad931d54d195899a094684344e902286037272890bce98a41813edc37a3cee190a693fcca613ee30049ce7ec2bdff9613f56778a13f8c28a21d167a"),
+			new Case(512, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c193", "08fca368b3b14ac406676adf37ac9be2dbb8704e694055a0c6331184d4f0070098f23f0963ee29002495771bf56fb4d3d9ff3506abcd80be927379f7880d5d7703919fbf92184f498ac44f47f015ce676eded9165d47d53733f5a27abbc05f45acd98b97cc15ffdced641defd1a5119ef841b452a1b8f94ee69004466ccdc143"),
+			new Case(512, 264, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "669e770ebe7eacc2b64caaf049923ad297a5b37cfa61c283392d81ccfcb9bbbc09"),
+			new Case(512, 1032, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e", "acc2e03f07f33e9820a6038421089429adcd6a7a83f733beec048c05bf37531a170a5537fcb565c348a70a83217f8be768ff6f95fd2b3d89cb7d8a3dc849505e3710eb4e65a8e7134bbf580d92fe18c9aa987563669b1f014aa5e092519089355534eaa9f0bdc99f6839f54080ffe74623254c906ecb8896b4346c3178a0bc2898"),
+			new Case(512, 2056, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "9f3e082223c43090a4a3ffbdcd469cbabfe0c1399d1edf45a5dfc18f4db5428928a76e979b8d0d5dffec0e6a59ada448c1ffbc06cc80a2006f002adc0c6dbf458563762228dce4381944e460ebebfe06f1237093634625107469a22a189a47f8b025899265d8890a1b39df64552394377e88ba2ad44a8c8d174f884ac8c3ae24ddb0affca5fceb6aa76e09706881e8371774b9b050a69b96ef5e97e81043f8b7e9479e287ab441bacd62caf768a82c8c3e3107be70eb8799a39856fe29842a04e25de0ef9de1b7e65bd0f1f7306835287fc957388e2035b7d22d3aa9c06a9fefbca16f3f60e1c4def89038d918942152a069aa2e0be8ae7475d859031adec84583"),
+			new Case(1024, 1024, "", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc81463134", "bcf37b3459c88959d6b6b58b2bfe142cef60c6f4ec56b0702480d7893a2b0595aa354e87102a788b61996b9cbc1eade7dafbf6581135572c09666d844c90f066b800fc4f5fd1737644894ef7d588afc5c38f5d920bdbd3b738aea3a3267d161ed65284d1f57da73b68817e17e381ca169115152b869c66b812bb9a84275303f0"),
+			new Case(1024, 1024, "d3090c72", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "df0596e5808835a3e304aa27923db05f61dac57c0696a1d19abf188e70aa9dbcc659e9510f7c9a37fbc025bd4e5ea293e78ed7838dd0b08864e8ad40ddb3a88031ebefc21572a89960d1916107a7da7ac0c067e34ec46a86a29ca63fa250bd398eb32ec1ed0f8ac8329f26da018b029e41e2e58d1dfc44de81615e6c987ed9c9"),
+			new Case(1024, 1024, "d3090c72167517f7", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c042eb4187aa1c015a4767032c0bb28f076b66485f51531c12e948f47dbc2cb904a4b75d1e8a6d931dab4a07e0a54d1bb5b55e602141746bd09fb15e8f01a8d74e9e63959cb37336bc1b896ec78da734c15e362db04368fbba280f20a043e0d0941e9f5193e1b360a33c43b266524880125222e648f05f28be34ba3cabfc9c544", "3cfbb79cd88af8ee09c7670bcbab6907a31f80fa31d9d7c9d50826c9568f307a78bd254961398c76b6e338fd9ca5f351059350d30963c3320659b223b991fc46d1307686fe2b4763d9f593c57ad5adbc45caf2ea3dc6090f5a74fa5fa6d9e9838964ea0a2aa216831ab069b00629a1a9b037083403bdb25d3d06a21c430c87dd"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e59", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "0a1b960099fc9d653b0fd1f5b6b972fb366907b772cbce5a59b6171d7935506f70c212bd169d68c5cfd8618343611b7eb2e686ff1dc7c03a57e1a55ed10726848161eea903d53b58459be42d95df989c66c2eea4e51cde272c2d8be67bf3bca2aee633777eb8486781eaa060d0f538abd6c93dbd2d1bf66e6f50bfdcac3725a4"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "3e0cd7938d71c39ffbb08a6ba7995ade3ad140e2c0c45cdbafb099247e08e4c20b61c1f885ced5ed2f816680925034918236e5807f0eecf3f27e9cfca36675eb75873efa1fb41f17541dc2f7c2469eaecb35cc7ca58e489804caf56f09fb97c9f689c64ad49c6888f86c483e901bd3d25798b394ef93faf9154900f92f31f433"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdf", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc81463134", "7266752f7e9aa04bd7d8a1b16030677de6021301f6a62473c76bae2b98bbf8aad73bd00a4b5035f741caf2317ab80e4e97f5c5bbe8acc0e8b424bcb13c7c6740a985801fba54addde8d4f13f69d2bfc98ae104d46a211145217e51d510ea846cec9581d14fda079f775c8b18d66cb31bf7060996ee8a69eee7f107909ce59a97"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c042eb4187aa1c015a4767032c0bb28f076b66485f51531c12e948f47dbc2cb904a4b75d1e8a6d931dab4a07e0a54d1bb5b55e602141746bd09fb15e8f01a8d74e9e63959cb37336bc1b896ec78da734c15e362db04368fbba280f20a043e0d0941e9f5193e1b360a33c43b266524880125222e648f05f28be34ba3cabfc9c544", "71f40bf2aa635125ef83c8df0d4e9ea18b73b56be4f45e89b910a7c68d396b65b09d18abc7d1b6de3f53fd5de583e6f22e612dd17b292068af6027daaf8b4cd60acf5bc85044741e9f7a1f423f5827f5e360930a2e71912239af9fc6343604fdcf3f3569854f2bb8d25a81e3b3f5261a02fe8292aaaa50c324101ab2c7a2f349"),
+			new Case(1024, 160, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "17c3c533b27d666da556ae586e641b7a3a0bcc45"),
+			new Case(1024, 224, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc81463134", "6625df9801581009125ea4e5c94ad6f1a2d692c278822ccb6eb67235"),
+			new Case(1024, 256, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "6c5b671c1766f6eecea6d24b641d4a6bf84bba13a1976f8f80b3f30ee2f93de6"),
+			new Case(1024, 384, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c042eb4187aa1c015a4767032c0bb28f076b66485f51531c12e948f47dbc2cb904a4b75d1e8a6d931dab4a07e0a54d1bb5b55e602141746bd09fb15e8f01a8d74e9e63959cb37336bc1b896ec78da734c15e362db04368fbba280f20a043e0d0941e9f5193e1b360a33c43b266524880125222e648f05f28be34ba3cabfc9c544", "98af454d7fa3706dfaafbf58c3f9944868b57f68f493987347a69fce19865febba0407a16b4e82065035651f0b1e0327"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1", "211ac479e9961141da3aac19d320a1dbbbfad55d2dce87e6a345fcd58e36827597378432b482d89bad44dddb13e6ad86e0ee1e0882b4eb0cd6a181e9685e18dd302ebb3aa74502c06254dcadfb2bd45d288f82366b7afc3bc0f6b1a3c2e8f84d37fbedd07a3f8fcff84faf24c53c11da600aaa118e76cfdcb366d0b3f7729dce"),
+			new Case(1024, 264, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc81463134", "dc1d253b7cadbdaef18503b1809a7f1d4f8c323b7f6f8ca50b76d3864649ce1c7d"),
+			new Case(1024, 520, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "decd79578d12bf6806530c382230a2c7836429c70cac941179e1dd982938bab91fb6f3638df1cc1ef615ecfc4249e5aca8a73c4c1eebef662a836d0be903b00146"),
+			new Case(1024, 1032, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c042eb4187aa1c015a4767032c0bb28f076b66485f51531c12e948f47dbc2cb904a4b75d1e8a6d931dab4a07e0a54d1bb5b55e602141746bd09fb15e8f01a8d74e9e63959cb37336bc1b896ec78da734c15e362db04368fbba280f20a043e0d0941e9f5193e1b360a33c43b266524880125222e648f05f28be34ba3cabfc9c544", "440fe691e04f1fed8c253d6c4670646156f33fffaea702de9445df5739eb960cecf85d56e2e6860a610211a5c909932ab774b978aa0b0d5bbce82775172ab12dceddd51d1eb030057ce61bea6c18f6bb368d26ae76a9e44a962eb132e6c42c25d9fecc4f13348300ca55c78e0990de96c1ae24eb3ee3324782c93dd628260a2c8d"),
+			new Case(1024, 1024, "d3090c72167517f7c7ad82a70c2fd3f6443f608301591e598eadb195e8357135ba26fede2ee187417f816048d00fc23512737a2113709a77e4170c49a94b7fdff45ff579a72287743102e7766c35ca5abc5dfe2f63a1e726ce5fbd2926db03a2dd18b03fc1508a9aac45eb362440203a323e09edee6324ee2e37b4432c1867ed696e6c9db1e6abea026288954a9c2d5758d7c5db7c9e48aa3d21cae3d977a7c3926066aa393dbd538dd0c30da8916c8757f24c18488014668a2627163a37b261833dc2f8c3c56b1b2e0be21fd3fbdb507b2950b77a6cc02efb393e57419383a920767bca2c972107aa61384542d47cbfb82cfe5c415389d1b0a2d74e2c5da851", "cb41f1706cde09651203c2d0efbaddf847a0d315cb2e53ff8bac41da0002672e920244c66e02d5f0dad3e94c42bb65f0d14157decf4105ef5609d5b0984457c1935df3061ff06e9f204192ba11e5bb2cac0430c1c370cb3d113fea5ec1021eb875e5946d7a96ac69a1626c6206b7252736f24253c9ee9b85eb852dfc814631346c", "46a42b0d7b8679f8fcea156c072cf9833c468a7d59ac5e5d326957d60dfe1cdfb27eb54c760b9e049fda47f0b847ac68d6b340c02c39d4a18c1bdfece3f405fae8aa848bdbefe3a4c277a095e921228618d3be8bd1999a071682810de748440ad416a97742cc9e8a9b85455b1d76472cf562f525116698d5cd0a35ddf86e7f8a"),
+
+		};
+
+		public override string Name
+		{
+			get { return "SkeinMac"; }
+		}
+
+		public override void PerformTest()
+		{
+			for (int i = 0; i < TEST_CASES.Length; i++)
+			{
+				Case test = TEST_CASES[i];
+				runTest(test);
+			}
+		}
+
+		private void runTest(Case dc)
+		{
+			IMac digest = new SkeinMac(dc.getBlockSize(), dc.getOutputSize());
+			digest.Init(new KeyParameter(dc.getKey()));
+
+			byte[] message = dc.getMessage();
+			digest.BlockUpdate(message, 0, message.Length);
+
+			byte[] output = new byte[digest.GetMacSize()];
+			digest.DoFinal(output, 0);
+
+			if (!AreEqual(output, dc.getDigest()))
+			{
+				Fail(digest.AlgorithmName + " message " + (dc.getMessage().Length * 8) + " mismatch.\n Message  " + Hex.ToHexString(dc.getMessage())
+				     + "\n Key      " + Hex.ToHexString(dc.getKey()) + "\n Expected "
+				     + Hex.ToHexString(dc.getDigest()) + "\n Actual   " + Hex.ToHexString(output));
+			}
+
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new SkeinMacTest());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+
+	}
+}
\ No newline at end of file
diff --git a/crypto/test/src/crypto/test/Sm3DigestTest.cs b/crypto/test/src/crypto/test/Sm3DigestTest.cs
new file mode 100644
index 000000000..3d004deaa
--- /dev/null
+++ b/crypto/test/src/crypto/test/Sm3DigestTest.cs
@@ -0,0 +1,74 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.Digests;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+	/**
+	 * standard vector test for SM3 digest from chinese specification
+	 */
+	[TestFixture]
+	public class Sm3DigestTest
+	    : DigestTest
+	{
+	    private static string[] messages = {
+	        // Standard test vectors
+	        "abc",
+	        "abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd",
+	        // Non-standard test vectors
+	        "",
+	        "a",
+	        "abcdefghijklmnopqrstuvwxyz",
+	    };
+
+	    private static string[] digests = {
+	        // Standard test vectors
+	        "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0",
+	        "debe9ff92275b8a138604889c18e5a4d6fdb70e5387e5765293dcba39c0c5732",
+	        // Non-standard test vectors
+	        "1ab21d8355cfa17f8e61194831e81a8f22bec8c728fefb747ed035eb5082aa2b",
+	        "623476ac18f65a2909e43c7fec61b49c7e764a91a18ccb82f1917a29c86c5e88",
+	        "b80fe97a4da24afc277564f66a359ef440462ad28dcc6d63adb24d5c20a61595",
+	    };
+
+	    private static string sixtyFourKdigest = "97049bdc8f0736bc7300eafa9980aeb9cf00f24f7ec3a8f1f8884954d7655c1d";
+	    private static string million_a_digest = "c8aaf89429554029e231941a2acc0ad61ff2a5acd8fadd25847a3a732b3b02c3";
+
+	    internal Sm3DigestTest()
+			: base(new Sm3Digest(), messages, digests)
+	    {
+	    }
+
+	    public override void PerformTest()
+	    {
+	        base.PerformTest();
+
+	        sixtyFourKTest(sixtyFourKdigest);
+	        millionATest(million_a_digest);
+	    }
+
+	    protected override IDigest CloneDigest(IDigest digest)
+	    {
+	        return new Sm3Digest((Sm3Digest)digest);
+	    }
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Sm3DigestTest());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
+}
diff --git a/crypto/test/src/crypto/test/Threefish1024Test.cs b/crypto/test/src/crypto/test/Threefish1024Test.cs
new file mode 100644
index 000000000..64f9aa29f
--- /dev/null
+++ b/crypto/test/src/crypto/test/Threefish1024Test.cs
@@ -0,0 +1,74 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto.Engines;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+
+	[TestFixture]
+	public class Threefish1024Test
+		: CipherTest
+	{
+		// Test cases from skein_golden_kat_internals.txt in Skein 1.3 NIST CD
+		static SimpleTest[] tests =
+		{
+			new BlockCipherVectorTest(0, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_1024),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(new byte[128]),
+				new byte[16]),
+			                          "0000000000000000000000000000000000000000000000000000000000000000" +
+			                          "0000000000000000000000000000000000000000000000000000000000000000" +
+			                          "0000000000000000000000000000000000000000000000000000000000000000" +
+			                          "0000000000000000000000000000000000000000000000000000000000000000",
+			                          "f05c3d0a3d05b304f785ddc7d1e036015c8aa76e2f217b06c6e1544c0bc1a90d" +
+			                          "f0accb9473c24e0fd54fea68057f43329cb454761d6df5cf7b2e9b3614fbd5a2" +
+			                          "0b2e4760b40603540d82eabc5482c171c832afbe68406bc39500367a592943fa" +
+			                          "9a5b4a43286ca3c4cf46104b443143d560a4b230488311df4feef7e1dfe8391e"),
+			new BlockCipherVectorTest(1, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_1024),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(Hex.Decode(
+				"101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f" +
+				"303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f" +
+				"505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f" +
+				"707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f")),
+				Hex.Decode("000102030405060708090a0b0c0d0e0f")),
+			                          "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0" +
+			                          "dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0" +
+			                          "bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a0" +
+			                          "9f9e9d9c9b9a999897969594939291908f8e8d8c8b8a89888786858483828180",
+			                          "a6654ddbd73cc3b05dd777105aa849bce49372eaaffc5568d254771bab85531c" +
+			                          "94f780e7ffaae430d5d8af8c70eebbe1760f3b42b737a89cb363490d670314bd" +
+			                          "8aa41ee63c2e1f45fbd477922f8360b388d6125ea6c7af0ad7056d01796e90c8" +
+			                          "3313f4150a5716b30ed5f569288ae974ce2b4347926fce57de44512177dd7cde")
+		};
+
+		public Threefish1024Test()
+			: base(tests, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_1024), new KeyParameter(new byte[128]))
+		{
+		}
+
+		public override string Name
+		{
+			get { return "Threefish-1024"; }
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Threefish1024Test());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
+}
diff --git a/crypto/test/src/crypto/test/Threefish256Test.cs b/crypto/test/src/crypto/test/Threefish256Test.cs
new file mode 100644
index 000000000..e44299a31
--- /dev/null
+++ b/crypto/test/src/crypto/test/Threefish256Test.cs
@@ -0,0 +1,59 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto.Engines;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+
+	[TestFixture]
+	public class Threefish256Test
+		: CipherTest
+	{
+		// Test cases from skein_golden_kat_internals.txt in Skein 1.3 NIST CD
+		static SimpleTest[] tests =
+		{
+			new BlockCipherVectorTest(0, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_256),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(new byte[32]),
+				new byte[16]),
+			                          "0000000000000000000000000000000000000000000000000000000000000000",
+			                          "84da2a1f8beaee947066ae3e3103f1ad536db1f4a1192495116b9f3ce6133fd8"),
+			new BlockCipherVectorTest(1, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_256),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(Hex.Decode(
+				"101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f")),
+				Hex.Decode("000102030405060708090a0b0c0d0e0f")),
+			                          "FFFEFDFCFBFAF9F8F7F6F5F4F3F2F1F0EFEEEDECEBEAE9E8E7E6E5E4E3E2E1E0",
+			                          "e0d091ff0eea8fdfc98192e62ed80ad59d865d08588df476657056b5955e97df")
+		};
+
+		public Threefish256Test()
+			: base(tests, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_256), new KeyParameter(new byte[32]))
+		{
+		}
+
+		public override string Name
+		{
+			get { return "Threefish-256"; }
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Threefish256Test());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
+}
\ No newline at end of file
diff --git a/crypto/test/src/crypto/test/Threefish512Test.cs b/crypto/test/src/crypto/test/Threefish512Test.cs
new file mode 100644
index 000000000..8f4ec6345
--- /dev/null
+++ b/crypto/test/src/crypto/test/Threefish512Test.cs
@@ -0,0 +1,64 @@
+using System;
+
+using NUnit.Framework;
+
+using Org.BouncyCastle.Crypto.Engines;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Utilities.Encoders;
+using Org.BouncyCastle.Utilities.Test;
+
+namespace Org.BouncyCastle.Crypto.Tests
+{
+
+	[TestFixture]
+	public class Threefish512Test
+		: CipherTest
+	{
+		// Test cases from skein_golden_kat_internals.txt in Skein 1.3 NIST CD
+		static SimpleTest[] tests =
+		{
+			new BlockCipherVectorTest(0, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_512),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(new byte[64]),
+				new byte[16]),
+			                          "0000000000000000000000000000000000000000000000000000000000000000" +
+			                          "0000000000000000000000000000000000000000000000000000000000000000",
+			                          "b1a2bbc6ef6025bc40eb3822161f36e375d1bb0aee3186fbd19e47c5d479947b" +
+			                          "7bc2f8586e35f0cff7e7f03084b0b7b1f1ab3961a580a3e97eb41ea14a6d7bbe"),
+			new BlockCipherVectorTest(1, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_512),
+			                          new TweakableBlockCipherParameters(
+				new KeyParameter(Hex.Decode(
+				"101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f" +
+				"303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f")),
+				Hex.Decode("000102030405060708090a0b0c0d0e0f")),
+			                          "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0" +
+			                          "dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0",
+			                          "e304439626d45a2cb401cad8d636249a6338330eb06d45dd8b36b90e97254779" +
+			                          "272a0a8d99463504784420ea18c9a725af11dffea10162348927673d5c1caf3d")
+		};
+
+		public Threefish512Test()
+			: base(tests, new ThreefishEngine(ThreefishEngine.BLOCKSIZE_512), new KeyParameter(new byte[64]))
+		{
+		}
+
+		public override string Name
+		{
+			get { return "Threefish-512"; }
+		}
+
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new Threefish512Test());
+		}
+
+		[Test]
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
+
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
+	}
+}
\ No newline at end of file
diff --git a/crypto/test/src/crypto/test/TigerDigestTest.cs b/crypto/test/src/crypto/test/TigerDigestTest.cs
index 6fec60185..21bcfe78d 100644
--- a/crypto/test/src/crypto/test/TigerDigestTest.cs
+++ b/crypto/test/src/crypto/test/TigerDigestTest.cs
@@ -20,7 +20,7 @@ namespace Org.BouncyCastle.Crypto.Tests
      */
     [TestFixture]
     public class TigerDigestTest
-        : ITest
+        : DigestTest
     {
         readonly static string[] messages =
         {
@@ -48,93 +48,35 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         readonly static string hash64k = "FDF4F5B35139F48E710E421BE5AF411DE1A8AAC333F26204";
 
-        public string Name
-        {
-			get { return "Tiger"; }
-        }
-
-		public ITestResult Perform()
-        {
-            IDigest digest = new TigerDigest();
-            byte[] resBuf = new byte[digest.GetDigestSize()];
-
-            for (int i = 0; i < messages.Length; i++)
-            {
-                byte[] m = Encoding.ASCII.GetBytes(messages[i]);
-                digest.BlockUpdate(m, 0, m.Length);
-                digest.DoFinal(resBuf, 0);
-
-                if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[i])))
-                {
-                    return new SimpleTestResult(false, Name + ": Vector " + i + " failed got " + Hex.ToHexString(resBuf));
-                }
-            }
-
-            //
-            // test 2
-            //
-            byte[] mm = Encoding.ASCII.GetBytes(messages[messages.Length-1]);
-
-            digest.BlockUpdate(mm, 0, mm.Length/2);
-
-            // clone the IDigest
-            IDigest d = new TigerDigest((TigerDigest)digest);
+		internal TigerDigestTest()
+			: base(new TigerDigest(), messages, digests)
+		{
+		}
 
-            digest.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            digest.DoFinal(resBuf, 0);
+		public override void PerformTest()
+		{
+			base.PerformTest();
 
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "Tiger failing clone test"
-                    + SimpleTest.NewLine
-                    + "    expected: " + digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
+			sixtyFourKTest(hash64k);
+		}
 
-            d.BlockUpdate(mm, mm.Length/2, mm.Length - mm.Length/2);
-            d.DoFinal(resBuf, 0);
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new TigerDigest((TigerDigest)digest);
+		}
 
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(digests[digests.Length-1])))
-            {
-                return new SimpleTestResult(false,
-                    "Tiger failing clone test - part 2"
-                    + SimpleTest.NewLine
-                    + "    expected: " +  digests[digests.Length-1]
-                    + SimpleTest.NewLine
-                    + "    got     : " + Hex.ToHexString(resBuf));
-            }
-
-            for (int i = 0; i < 65536; i++)
-            {
-                digest.Update((byte)(i & 0xff));
-            }
-            digest.DoFinal(resBuf, 0);
-
-            if (!Arrays.AreEqual(resBuf, Hex.Decode(hash64k)))
-            {
-                return new SimpleTestResult(false, Name + ": Million a's failed");
-            }
-
-            return new SimpleTestResult(true, Name + ": Okay");
-        }
-
-        public static void Main(
-            string[] args)
-        {
-            ITest test = new TigerDigestTest();
-            ITestResult result = test.Perform();
-
-            Console.WriteLine(result);
-        }
+		public static void Main(
+			string[] args)
+		{
+			RunTest(new TigerDigestTest());
+		}
 
 		[Test]
-        public void TestFunction()
-        {
-            string resultText = Perform().ToString();
+		public void TestFunction()
+		{
+			string resultText = Perform().ToString();
 
-            Assert.AreEqual(Name + ": Okay", resultText);
-        }
+			Assert.AreEqual(Name + ": Okay", resultText);
+		}
     }
 }
diff --git a/crypto/test/src/crypto/test/WhirlpoolDigestTest.cs b/crypto/test/src/crypto/test/WhirlpoolDigestTest.cs
index 865408f6a..eff9b1c2e 100644
--- a/crypto/test/src/crypto/test/WhirlpoolDigestTest.cs
+++ b/crypto/test/src/crypto/test/WhirlpoolDigestTest.cs
@@ -5,135 +5,107 @@ using NUnit.Framework;
 
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
+using Org.BouncyCastle.Crypto.Engines;
+using Org.BouncyCastle.Crypto.Encodings;
+using Org.BouncyCastle.Crypto.Parameters;
+using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
 {
+
 	/**
 	 * ISO vector test for Whirlpool
-	 *
+	 *  
 	 */
 	[TestFixture]
 	public class WhirlpoolDigestTest
-		: SimpleTest
+		: DigestTest
 	{
-		private static string[][] _isoVectors =
+		private static string[] messages =
 		{
-			new string[]
-			{
-				"",
-				"19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3"
-			},
-			new string[]
-			{
-				"a",
-				"8ACA2602792AEC6F11A67206531FB7D7F0DFF59413145E6973C45001D0087B42D11BC645413AEFF63A42391A39145A591A92200D560195E53B478584FDAE231A"
-			},
-			new string[]
-			{
-				"abc",
-				"4E2448A4C6F486BB16B6562C73B4020BF3043E3A731BCE721AE1B303D97E6D4C7181EEBDB6C57E277D0E34957114CBD6C797FC9D95D8B582D225292076D4EEF5"
-			},
-			new string[]
-			{
-				"message digest",
-				"378C84A4126E2DC6E56DCC7458377AAC838D00032230F53CE1F5700C0FFB4D3B8421557659EF55C106B4B52AC5A4AAA692ED920052838F3362E86DBD37A8903E"
-			},
-			new string[]
-			{
-				"abcdefghijklmnopqrstuvwxyz",
-				"F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B"
-			},
-			new string[]
-			{
-				"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
-				"DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E08EBA26629129D8FB7CB57211B9281A65517CC879D7B962142C65F5A7AF01467"
-			},
-			new string[]
-			{
-				"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
-				"466EF18BABB0154D25B9D38A6414F5C08784372BCCB204D6549C4AFADB6014294D5BD8DF2A6C44E538CD047B2681A51A2C60481E88C5A20B2C2A80CF3A9A083B"
-			},
-			new string[]
-			{
-				"abcdbcdecdefdefgefghfghighijhijk",
-				"2A987EA40F917061F5D6F0A0E4644F488A7A5A52DEEE656207C562F988E95C6916BDC8031BC5BE1B7B947639FE050B56939BAAA0ADFF9AE6745B7B181C3BE3FD"
-			}
+			"",
+			"a",
+			"abc",
+			"message digest",
+			"abcdefghijklmnopqrstuvwxyz",
+			"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+			"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+			"abcdbcdecdefdefgefghfghighijhijk"
+		};
+
+		private static string[] digests =
+		{
+			"19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3",
+			"8ACA2602792AEC6F11A67206531FB7D7F0DFF59413145E6973C45001D0087B42D11BC645413AEFF63A42391A39145A591A92200D560195E53B478584FDAE231A",
+			"4E2448A4C6F486BB16B6562C73B4020BF3043E3A731BCE721AE1B303D97E6D4C7181EEBDB6C57E277D0E34957114CBD6C797FC9D95D8B582D225292076D4EEF5",
+			"378C84A4126E2DC6E56DCC7458377AAC838D00032230F53CE1F5700C0FFB4D3B8421557659EF55C106B4B52AC5A4AAA692ED920052838F3362E86DBD37A8903E",
+			"F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B",
+			"DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E08EBA26629129D8FB7CB57211B9281A65517CC879D7B962142C65F5A7AF01467",
+			"466EF18BABB0154D25B9D38A6414F5C08784372BCCB204D6549C4AFADB6014294D5BD8DF2A6C44E538CD047B2681A51A2C60481E88C5A20B2C2A80CF3A9A083B",
+			"2A987EA40F917061F5D6F0A0E4644F488A7A5A52DEEE656207C562F988E95C6916BDC8031BC5BE1B7B947639FE050B56939BAAA0ADFF9AE6745B7B181C3BE3FD"
 		};
 
 		private static string _millionAResultVector = "0C99005BEB57EFF50A7CF005560DDF5D29057FD86B20BFD62DECA0F1CCEA4AF51FC15490EDDC47AF32BB2B66C34FF9AD8C6008AD677F77126953B226E4ED8B01";
 
 		private static string _thirtyOneZeros = "3E3F188F8FEBBEB17A933FEAF7FE53A4858D80C915AD6A1418F0318E68D49B4E459223CD414E0FBC8A57578FD755D86E827ABEF4070FC1503E25D99E382F72BA";
 
-		public override string Name
+		internal WhirlpoolDigestTest()
+			: base(new WhirlpoolDigest(), messages, digests)
 		{
-			get
-			{
-				return "Whirlpool";
-			}
 		}
 
 		public override void PerformTest()
 		{
-			for (int i = 0; i < _isoVectors.Length; i++)
-			{
-				performStandardVectorTest("ISO vector test ["+i+"]", _isoVectors[i][0],
-					_isoVectors[i][1]);
-			}
+			base.PerformTest();
 
 			byte[] thirtyOneZeros = new byte[31];
-			performStandardVectorTest("31 zeroes test",
-				thirtyOneZeros, _thirtyOneZeros);
+			performStandardVectorTest("31 zeroes test", 
+			                          thirtyOneZeros, _thirtyOneZeros);
 
 			byte[] millionAInByteArray = new byte[1000000];
-//			Arrays.fill(millionAInByteArray, (byte)'a');
-			for (int ai = 0; ai < millionAInByteArray.Length; ++ai)
-			{
-				millionAInByteArray[ai] = (byte) 'a';
-			}
+			Arrays.Fill(millionAInByteArray, (byte)'a');
 
-			performStandardVectorTest("Million 'a' test",
-				millionAInByteArray, _millionAResultVector);
+			performStandardVectorTest("Million 'a' test", 
+			                          millionAInByteArray, _millionAResultVector);
 		}
 
 		private void performStandardVectorTest(string testTitle, byte[] inputBytes,
-			string resultsAsHex)
+		                                       string resultsAsHex)
 		{
-			doPerformTest(testTitle, inputBytes, resultsAsHex);
+			doPerformTest(testTitle, inputBytes, resultsAsHex);        
 		}
 
 		private void doPerformTest(string testTitle, byte[] inputBytes, string resultsAsHex)
 		{
 			string resStr = createHexOutputFromDigest(inputBytes);
-			if (resultsAsHex != resStr.ToUpper())
+			if (!resultsAsHex.Equals(resStr.ToUpper()))
 			{
 				Fail(testTitle, resultsAsHex, resStr);
 			}
 		}
 
-		private void performStandardVectorTest(string testTitle, string inputBytesAsString,
-			string resultsAsHex)
-		{
-			doPerformTest(testTitle, Encoding.ASCII.GetBytes(inputBytesAsString), resultsAsHex);
-		}
-
 		private string createHexOutputFromDigest(byte[] digestBytes)
 		{
+			string resStr;
 			IDigest digest = new WhirlpoolDigest();
 			byte[] resBuf = new byte[digest.GetDigestSize()];
 			digest.BlockUpdate(digestBytes, 0, digestBytes.Length);
 			digest.DoFinal(resBuf, 0);
-			return Hex.ToHexString(resBuf);
+			resStr = Hex.ToHexString(resBuf);
+			return resStr;
+		}
+
+		protected override IDigest CloneDigest(IDigest digest)
+		{
+			return new WhirlpoolDigest((WhirlpoolDigest)digest);
 		}
 
 		public static void Main(
 			string[] args)
 		{
-			WhirlpoolDigestTest test = new WhirlpoolDigestTest();
-			ITestResult result = test.Perform();
-
-			Console.WriteLine(result);
+			RunTest(new WhirlpoolDigestTest());
 		}
 
 		[Test]