Merge pull request #249 from pcc/xgetinputfocus
[mono.git] / mcs / class / System.Core / Test / System.Security.Cryptography / SHA384CryptoServiceProviderTest.cs
1 //
2 // SHA384CryptoServiceProviderTest.cs - NUnit Test Cases for SHA384CryptoServiceProvider
3 //
4 // Author:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004, 2007-2008 Novell, Inc (http://www.novell.com)
9 //
10
11 using NUnit.Framework;
12 using System;
13 using System.Security.Cryptography;
14 using System.Text;
15
16 namespace MonoTests.System.Security.Cryptography {
17
18         // References:
19         // a.   FIPS PUB 180-2: Secure Hash Standard
20         //      http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
21
22         // we inherit from SHA384Test because all SHA384 implementation must return the 
23         // same results (hence should run a common set of unit tests).
24
25         [TestFixture]
26         public class SHA384CryptoServiceProviderTest : SHA384Test {
27
28                 [SetUp]
29                 public override void SetUp ()
30                 {
31                         hash = new SHA384CryptoServiceProvider ();
32                 }
33
34                 [Test]
35                 public override void Create ()
36                 {
37                         // no need to repeat this test
38                 }
39
40                 // none of those values changes for a particuliar implementation of SHA384
41                 [Test]
42                 public override void StaticInfo ()
43                 {
44                         // test all values static for SHA384
45                         base.StaticInfo ();
46                         string className = hash.ToString ();
47                         Assert.IsTrue (hash.CanReuseTransform, className + ".CanReuseTransform");
48                         Assert.IsTrue (hash.CanTransformMultipleBlocks, className + ".CanTransformMultipleBlocks");
49                         Assert.AreEqual ("System.Security.Cryptography.SHA384CryptoServiceProvider", className, className + ".ToString()");
50                 }
51
52                 [Test]
53                 public void FIPSCompliance_Test1 ()
54                 {
55                         SHA384 sha = (SHA384) hash;
56                         // First test, we hash the string "abc"
57                         FIPS186_Test1 (sha);
58                 }
59
60                 [Test]
61                 public void FIPSCompliance_Test2 ()
62                 {
63                         SHA384 sha = (SHA384) hash;
64                         // Second test, we hash the string "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
65                         FIPS186_Test2 (sha);
66                 }
67
68                 [Test]
69                 public void FIPSCompliance_Test3 ()
70                 {
71                         SHA384 sha = (SHA384) hash;
72                         // Third test, we hash 1,000,000 times the character "a"
73                         FIPS186_Test3 (sha);
74                 }
75         }
76 }