2006-10-11 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.Security / System.Security.Cryptography.Xml / SignedXml.cs
index 4d30baa407f58959b45003717ba4fc06b8704c5f..0deb351d9d15c09678bd9dfd2bd60476a1206086 100644 (file)
@@ -623,8 +623,11 @@ namespace System.Security.Cryptography.Xml {
                public void ComputeSignature () 
                {
                        if (key != null) {
-                               // required before hashing
-                               m_signature.SignedInfo.SignatureMethod = key.SignatureAlgorithm;
+                               if (m_signature.SignedInfo.SignatureMethod == null)
+                                       // required before hashing
+                                       m_signature.SignedInfo.SignatureMethod = key.SignatureAlgorithm;
+                               else if (m_signature.SignedInfo.SignatureMethod != key.SignatureAlgorithm)
+                                       throw new CryptographicException ("Specified SignatureAlgorithm is not supported by the signing key.");
                                DigestReferences ();
 
                                AsymmetricSignatureFormatter signer = null;