Author: atsushi
Date: 2007-01-12 03:09:57 -0500 (Fri, 12 Jan 2007)
New Revision: 70902

Modified:
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityUtility.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
Log:
2007-01-12  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * SecureMessageGenerator.cs : wrong key was used for signing.
          Omit KeyInfo for now - it seems that .net (sometimes?) omits it.



Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-01-12 08:08:44 UTC (rev 70901)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-01-12 08:09:57 UTC (rev 70902)
@@ -1,3 +1,8 @@
+2007-01-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SecureMessageGenerator.cs : wrong key was used for signing.
+         Omit KeyInfo for now - it seems that .net (sometimes?) omits it.
+
 2007-01-11  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SecureMessageGenerator.cs :

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityUtility.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityUtility.cs
        2007-01-12 08:08:44 UTC (rev 70901)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityUtility.cs
        2007-01-12 08:09:57 UTC (rev 70902)
@@ -197,12 +197,12 @@
                                if (ed2.GetXml () == null) throw new Exception 
("Gyabo");
                                encXml.ReplaceData (el, DecryptLax (encXml, 
ed2, aes));
                        }
-/*
+
 Console.WriteLine ("======== Decrypted Document ========");
 doc.PreserveWhitespace = false;
 doc.Save (Console.Out);
 doc.PreserveWhitespace = true;
-*/
+
                        if (security.SelectSingleNode ("dsig:Signature", nsmgr) 
== null)
                                throw new MessageSecurityException ("The the 
message signature is expected but not found.");
                }

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
        2007-01-12 08:08:44 UTC (rev 70901)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
        2007-01-12 08:09:57 UTC (rev 70902)
@@ -289,13 +289,9 @@
 
                        SecurityKeyIdentifierClause encClause =
                                initiatorParams.CallCreateKeyIdentifierClause 
(encToken, msgIncludesToken ? initiatorParams.ReferenceStyle : 
SecurityTokenReferenceStyle.External);
-                       SecurityKeyIdentifierClause signClause =
-                               recipientParams.CallCreateKeyIdentifierClause 
(signToken, msgIncludesToken ? recipientParams.ReferenceStyle : 
SecurityTokenReferenceStyle.External);
 
                        AsymmetricSecurityKey encKey = (AsymmetricSecurityKey) 
                                encToken.ResolveKeyIdentifierClause (encClause);
-                       AsymmetricSecurityKey signKey = (AsymmetricSecurityKey) 
-                               signToken.ResolveKeyIdentifierClause 
(signClause);
 
                        XmlElement body = doc.SelectSingleNode 
("/s:Envelope/s:Body/*", nsmgr) as XmlElement;
 
@@ -338,6 +334,8 @@
                                encToken,
                                new SecurityKeyIdentifier (encClause));
 
+                       SecurityKeyIdentifierClause ekeyClause =
+                               new LocalIdKeyIdentifierClause (ekeyId, typeof 
(WrappedKeySecurityToken));
 
                        switch (protectionOrder) {
                        case MessageProtectionOrder.EncryptBeforeSign:
@@ -352,8 +350,13 @@
                                HMACSHA1 sigHash = null;
                                if (security.DefaultSignatureAlgorithm == 
SignedXml.XmlDsigHMACSHA1Url)
                                        sigHash = new HMACSHA1 (aes.Key);
-                               else
+                               else {
+                                       // not sure if it is correct ...
+                                       SecurityKeyIdentifierClause signClause =
+                                               
recipientParams.CallCreateKeyIdentifierClause (signToken, msgIncludesToken ? 
recipientParams.ReferenceStyle : SecurityTokenReferenceStyle.External);
+                                       AsymmetricSecurityKey signKey = 
(AsymmetricSecurityKey) signToken.ResolveKeyIdentifierClause (signClause);
                                        sxml.SigningKey = 
signKey.GetAsymmetricAlgorithm (security.DefaultSignatureAlgorithm, true);
+                               }
 
                                sig = sxml.Signature;
                                sig.SignedInfo.CanonicalizationMethod =
@@ -374,7 +377,7 @@
                                else
                                        sxml.ComputeSignature ();
                                sxml.KeyInfo = new KeyInfo ();
-                               SecurityTokenReferenceKeyInfo sigKeyInfo = new 
SecurityTokenReferenceKeyInfo (signClause, serializer, doc);
+                               SecurityTokenReferenceKeyInfo sigKeyInfo = new 
SecurityTokenReferenceKeyInfo (ekeyClause, serializer, doc);
                                sxml.KeyInfo.AddClause (sigKeyInfo);
 
                                // encrypt
@@ -393,7 +396,7 @@
                                // encrypt signature
                                if (protectionOrder == 
MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature) {
                                        XmlElement sigxml = sig.GetXml ();
-                                       sigenc = Encrypt (sigxml, aes, ekeyId, 
refList, encClause, exml, doc);
+                                       sigenc = Encrypt (sigxml, aes, ekeyId, 
refList, ekeyClause, exml, doc);
                                }
                                break;
                        }
@@ -468,11 +471,11 @@
                        // with S.S.C.Xml.EncryptionMethod, we will have to
                        // build our own XML encryption classes.
 
-                       edata.KeyInfo = new KeyInfo ();
-                       LocalIdKeyIdentifierClause ident =
-                               new LocalIdKeyIdentifierClause (ekeyId);
-                       KeyInfoClause kic = new SecurityTokenReferenceKeyInfo 
(ident, serializer, doc);
-                       edata.KeyInfo.AddClause (kic);
+// FIXME: sometimes? always? it is omitted.
+//                     edata.KeyInfo = new KeyInfo ();
+//                     KeyInfoClause kic = new SecurityTokenReferenceKeyInfo 
(encClause, serializer, doc);
+//                     edata.KeyInfo.AddClause (kic);
+edata.KeyInfo = null;
                        edata.CipherData.CipherValue = encrypted;
 
                        DataReference dr = new DataReference ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to