2 // SignatureKeyTest.cs - NUnit Test Cases for SignatureKey
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
10 using NUnit.Framework;
11 using Microsoft.Web.Services.Security;
13 using System.Security.Cryptography;
14 using System.Web.Services.Protocols;
16 namespace MonoTests.MS.Web.Services.Security {
19 public class SignatureKeyTest : Assertion {
22 [ExpectedException (typeof (ArgumentNullException))]
23 public void ConstructorAsymmetricNull ()
25 AsymmetricAlgorithm key = null; // resolve ambiguity
26 SignatureKey aek = new SignatureKey (key);
30 [ExpectedException (typeof (ArgumentNullException))]
31 public void ConstructorSymmetricNull ()
33 SymmetricAlgorithm key = null; // resolve ambiguity
34 SignatureKey aek = new SignatureKey (key);
38 [ExpectedException (typeof (ArgumentNullException))]
39 public void ComputeSignatureNull ()
41 DSA dsa = DSA.Create ();
42 dsa.ImportParameters (AllTests.GetDSAKey (true));
43 SignatureKey sk = new SignatureKey (dsa);
44 sk.ComputeSignature (null);
48 public void ComputeSignatureDSA ()
50 DSA dsa = DSA.Create ();
51 dsa.ImportParameters (AllTests.GetDSAKey (true));
52 SignatureKey sk = new SignatureKey (dsa);
54 SignedXml signedXml = new SignedXml ();
55 Reference r = new Reference ("http://www.go-mono.com/");
56 signedXml.AddReference (r);
57 sk.ComputeSignature (signedXml);
61 public void ComputeSignatureRSA ()
63 RSA rsa = RSA.Create ();
64 rsa.ImportParameters (AllTests.GetRSAKey (true));
65 SignatureKey sk = new SignatureKey (rsa);
67 SignedXml signedXml = new SignedXml ();
68 Reference r = new Reference ("http://www.go-mono.com/");
69 signedXml.AddReference (r);
70 sk.ComputeSignature (signedXml);
74 public void ComputeSignatureSymmetricAlgo ()
76 // default (should be Rjindael)
77 SymmetricAlgorithm sa = SymmetricAlgorithm.Create ();
78 sa.Key = new byte [16]; // 128 bits (all zeros)
79 SignatureKey sk = new SignatureKey (sa);
81 SignedXml signedXml = new SignedXml ();
82 Reference r = new Reference ("http://www.go-mono.com/");
83 signedXml.AddReference (r);
84 sk.ComputeSignature (signedXml);