2 // TripleDESTest.cs - NUnit Test Cases for TripleDES
5 // Sebastien Pouliot (sebastien@ximian.com)
7 // (C) 2004 Novell (http://www.novell.com)
10 using NUnit.Framework;
12 using System.Security.Cryptography;
14 namespace MonoTests.System.Security.Cryptography {
17 public class TripleDESTest : Assertion {
22 TripleDES algo = TripleDES.Create ();
25 AssertEquals ("Key Size", 192, algo.KeySize);
26 AssertEquals ("Key Length", 24, algo.Key.Length);
27 AssertEquals ("IV Length", 8, algo.IV.Length);
31 [ExpectedException (typeof (ArgumentNullException))]
32 public void KeyNull ()
34 TripleDES algo = TripleDES.Create ();
39 [ExpectedException (typeof (CryptographicException))]
40 public void KeyWeak128bits ()
42 byte[] wk128 = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
43 TripleDES algo = TripleDES.Create ();
48 [ExpectedException (typeof (CryptographicException))]
49 public void KeyWeak192bits_AB ()
51 byte[] wk192 = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD };
52 TripleDES algo = TripleDES.Create ();
57 [ExpectedException (typeof (CryptographicException))]
58 public void KeyWeak192bits_BC ()
60 byte[] wk192 = { 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
61 TripleDES algo = TripleDES.Create ();
66 [ExpectedException (typeof (CryptographicException))]
67 public void KeyWrongLength ()
69 byte[] wk64 = { 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD };
70 TripleDES algo = TripleDES.Create ();