SHA384ManagedTest.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // SHA384ManagedTest.cs - NUnit Test Cases for SHA384Managed
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using NUnit.Framework;
  10. using System;
  11. using System.Security.Cryptography;
  12. using System.Text;
  13. namespace MonoTests.System.Security.Cryptography {
  14. // References:
  15. // a. FIPS PUB 180-2: Secure Hash Standard
  16. // http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
  17. // we inherit from SHA384Test because all SHA384 implementation must return the
  18. // same results (hence should run a common set of unit tests).
  19. public class SHA384ManagedTest : SHA384Test {
  20. protected override void SetUp ()
  21. {
  22. hash = new SHA384Managed ();
  23. }
  24. protected override void TearDown () {}
  25. public override void TestCreate ()
  26. {
  27. // no need to repeat this test
  28. }
  29. // none of those values changes for a particuliar implementation of SHA384
  30. public override void TestStaticInfo ()
  31. {
  32. // test all values static for SHA384
  33. base.TestStaticInfo ();
  34. string className = hash.ToString ();
  35. AssertEquals (className + ".CanReuseTransform", true, hash.CanReuseTransform);
  36. AssertEquals (className + ".CanTransformMultipleBlocks", true, hash.CanTransformMultipleBlocks);
  37. AssertEquals (className + ".ToString()", "System.Security.Cryptography.SHA384Managed", className);
  38. }
  39. public void TestSHA384forFIPSCompliance ()
  40. {
  41. SHA384 sha = (SHA384) hash;
  42. // First test, we hash the string "abc"
  43. FIPS186_Test1 (sha);
  44. // Second test, we hash the string "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
  45. FIPS186_Test2 (sha);
  46. // Third test, we hash 1,000,000 times the character "a"
  47. FIPS186_Test3 (sha);
  48. }
  49. }
  50. }