2 // SHA256CryptoServiceProviderTest.cs - NUnit Test Cases for SHA256CryptoServiceProvider
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004, 2007-2008 Novell, Inc (http://www.novell.com)
13 using NUnit.Framework;
15 using System.Security.Cryptography;
18 namespace MonoTests.System.Security.Cryptography {
21 // a. FIPS PUB 180-2: Secure Hash Standard
22 // http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
24 // we inherit from SHA256Test because all SHA256 implementation must return the
25 // same results (hence should run a common set of unit tests).
28 public class SHA256CryptoServiceProviderTest : SHA256Test {
31 public override void SetUp ()
33 hash = new SHA256CryptoServiceProvider ();
37 public override void Create ()
39 // no need to repeat this test
42 // none of those values changes for a particuliar implementation of SHA256
44 public override void StaticInfo ()
46 // test all values static for SHA256
48 string className = hash.ToString ();
49 Assert.IsTrue (hash.CanReuseTransform, className + ".CanReuseTransform");
50 Assert.IsTrue (hash.CanTransformMultipleBlocks, className + ".CanTransformMultipleBlocks");
51 Assert.AreEqual ("System.Security.Cryptography.SHA256CryptoServiceProvider", className, className + ".ToString()");
55 public void FIPSCompliance_Test1 ()
57 SHA256 sha = (SHA256) hash;
58 // First test, we hash the string "abc"
63 public void FIPSCompliance_Test2 ()
65 SHA256 sha = (SHA256) hash;
66 // Second test, we hash the string "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
71 public void FIPSCompliance_Test3 ()
73 SHA256 sha = (SHA256) hash;
74 // Third test, we hash 1,000,000 times the character "a"