Author: atsushi
Date: 2007-01-15 03:40:55 -0500 (Mon, 15 Jan 2007)
New Revision: 71007

Modified:
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
Log:
2007-01-15  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * SecurityAlgorithmSuite.cs : give more meaningful field names.
          Implemented some Is[blah]Supported() methods.
        * WSSecurityTokenSerializer.cs : corcompare fix.
        * SecurityVersion : removed MonoTODO.

        * WSSecurityTokenSerializerTest.cs: some tests for writing derived-
          key-involved key identifier clauses.



Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog    
    2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog    
    2007-01-15 08:40:55 UTC (rev 71007)
@@ -1,3 +1,10 @@
+2007-01-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * SecurityAlgorithmSuite.cs : give more meaningful field names.
+         Implemented some Is[blah]Supported() methods.
+       * WSSecurityTokenSerializer.cs : corcompare fix.
+       * SecurityVersion : removed MonoTODO.
+
 2007-01-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * ServiceCredentialsSecurityTokenManager.cs :

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs
        2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs
        2007-01-15 08:40:55 UTC (rev 71007)
@@ -33,7 +33,6 @@
 
 namespace System.ServiceModel.Security
 {
-       [MonoTODO]
        public abstract class SecurityAlgorithmSuite
        {
                #region Internal Class
@@ -44,6 +43,48 @@
                                : base (size, sha, rsa, false)
                        {
                        }
+
+                       public override int DefaultSignatureKeyDerivationLength 
{
+                               get { return Size > 192 ? 192 : Size; }
+                       }
+
+                       public override bool IsAsymmetricKeyLengthSupported 
(int length)
+                       {
+                               switch (length) {
+                               case 128:
+                               case 192:
+                                       return Size >= length;
+                               }
+                               return false;
+                       }
+
+                       public override bool IsSymmetricKeyLengthSupported (int 
length)
+                       {
+                               switch (length) {
+                               case 128:
+                               case 192:
+                               case 256:
+                                       return Size >= length;
+                               }
+                               return false;
+                       }
+
+                       public override bool 
IsSymmetricKeyWrapAlgorithmSupported (string algorithm)
+                       {
+                               switch (Size) {
+                               case 256:
+                                       if (algorithm == 
EncryptedXml.XmlEncAES256KeyWrapUrl)
+                                               return true;
+                                       goto case 192;
+                               case 192:
+                                       if (algorithm == 
EncryptedXml.XmlEncAES192KeyWrapUrl)
+                                               return true;
+                                       goto case 128;
+                               case 128:
+                                       return algorithm == 
EncryptedXml.XmlEncAES128KeyWrapUrl;
+                               }
+                               return false;
+                       }
                }
 
                class TripleDESSecurityAlgorithmSuite : 
SecurityAlgorithmSuiteImplBase
@@ -52,19 +93,39 @@
                                : base (192, sha, rsa, true)
                        {
                        }
+
+                       public override int DefaultSignatureKeyDerivationLength 
{
+                               get { return 192; }
+                       }
+
+                       public override bool IsAsymmetricKeyLengthSupported 
(int length)
+                       {
+                               return length == 192;
+                       }
+
+                       public override bool IsSymmetricKeyLengthSupported (int 
length)
+                       {
+                               return length == 192;
+                       }
+
+                       public override bool 
IsSymmetricKeyWrapAlgorithmSupported (
+                               string algorithm)
+                       {
+                               return algorithm == 
EncryptedXml.XmlEncTripleDESKeyWrapUrl;
+                       }
                }
 
-               class SecurityAlgorithmSuiteImplBase : SecurityAlgorithmSuite
+               abstract class SecurityAlgorithmSuiteImplBase : 
SecurityAlgorithmSuite
                {
                        int size;
-                       bool rsa, sha, tdes;
+                       bool rsa15, sha256, tdes;
 
                        public SecurityAlgorithmSuiteImplBase (
-                               int size, bool sha, bool rsa, bool tripleDes)
+                               int size, bool sha256, bool rsa15, bool 
tripleDes)
                        {
                                this.size = size;
-                               this.sha = sha;
-                               this.rsa = rsa;
+                               this.sha256 = sha256;
+                               this.rsa15 = rsa15;
                                this.tdes = tripleDes;
                        }
 
@@ -72,20 +133,20 @@
                                get { return size; }
                        }
 
-                       public bool Rsa {
-                               get { return rsa; }
+                       public bool Rsa15 {
+                               get { return rsa15; }
                        }
 
-                       public bool Sha {
-                               get { return sha; }
+                       public bool Sha256 {
+                               get { return sha256; }
                        }
 
                        public override string 
DefaultAsymmetricKeyWrapAlgorithm {
-                               get { return rsa ? EncryptedXml.XmlEncRSA15Url 
: EncryptedXml.XmlEncRSAOAEPUrl; }
+                               get { return rsa15 ? 
EncryptedXml.XmlEncRSA15Url : EncryptedXml.XmlEncRSAOAEPUrl; }
                        }
 
                        public override string 
DefaultAsymmetricSignatureAlgorithm {
-                               get { return sha ? 
SecurityAlgorithms.RsaSha256Signature : SignedXml.XmlDsigRSASHA1Url; }
+                               get { return sha256 ? 
SecurityAlgorithms.RsaSha256Signature : SignedXml.XmlDsigRSASHA1Url; }
                        }
 
                        public override string DefaultCanonicalizationAlgorithm 
{
@@ -94,7 +155,7 @@
 
 
                        public override string DefaultDigestAlgorithm {
-                               get { return sha ? EncryptedXml.XmlEncSHA256Url 
: SignedXml.XmlDsigSHA1Url; }
+                               get { return sha256 ? 
EncryptedXml.XmlEncSHA256Url : SignedXml.XmlDsigSHA1Url; }
                        }
 
                        public override string DefaultEncryptionAlgorithm {
@@ -117,11 +178,6 @@
                                get { return size; }
                        }
 
-                       public override int DefaultSignatureKeyDerivationLength 
{
-                               // FIXME: find out the reason why.
-                               get { return size == 256 ? 192 : size; }
-                       }
-
                        public override int DefaultSymmetricKeyLength {
                                get { return size; }
                        }
@@ -143,27 +199,10 @@
                        }
 
                        public override string 
DefaultSymmetricSignatureAlgorithm {
-                               get { return sha ? 
SecurityAlgorithms.HmacSha256Signature : SignedXml.XmlDsigHMACSHA1Url; }
+                               get { return sha256 ? 
SecurityAlgorithms.HmacSha256Signature : SignedXml.XmlDsigHMACSHA1Url; }
                        }
 
-                       public override bool IsAsymmetricKeyLengthSupported 
(int length)
-                       {
-                               throw new NotImplementedException ();
-                       }
-
-                       public override bool IsSymmetricKeyLengthSupported (int 
length)
-                       {
-                               throw new NotImplementedException ();
-                       }
-
                        [MonoTODO]
-                       public override bool 
IsAsymmetricKeyWrapAlgorithmSupported (
-                               string algorithm)
-                       {
-                               throw new NotImplementedException ();
-                       }
-
-                       [MonoTODO]
                        public override bool 
IsAsymmetricSignatureAlgorithmSupported (
                                string algorithm)
                        {
@@ -205,13 +244,6 @@
                        }
 
                        [MonoTODO]
-                       public override bool 
IsSymmetricKeyWrapAlgorithmSupported (
-                               string algorithm)
-                       {
-                               throw new NotImplementedException ();
-                       }
-
-                       [MonoTODO]
                        public override bool 
IsSymmetricSignatureAlgorithmSupported (
                                string algorithm)
                        {
@@ -248,87 +280,70 @@
                        tdes_sr = new TripleDESSecurityAlgorithmSuite (true, 
true);
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Default {
                        get { return Basic256; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic128 {
                        get { return b128; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic128Rsa15 {
                        get { return b128r; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic128Sha256 {
                        get { return b128s; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic128Sha256Rsa15 {
                        get { return b128sr; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic192 {
                        get { return b192; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic192Rsa15 {
                        get { return b192r; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic192Sha256 {
                        get { return b192s; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic192Sha256Rsa15 {
                        get { return b192sr; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic256 {
                        get { return b256; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic256Rsa15 {
                        get { return b256r; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic256Sha256 {
                        get { return b256s; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite Basic256Sha256Rsa15 {
                        get { return b256sr; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite TripleDes {
                        get { return tdes; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite TripleDesRsa15 {
                        get { return tdes_r; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite TripleDesSha256 {
                        get { return tdes_s; }
                }
 
-               [MonoTODO]
                public static SecurityAlgorithmSuite TripleDesSha256Rsa15 {
                        get { return tdes_sr; }
                }
@@ -361,20 +376,18 @@
 
                public abstract string DefaultSymmetricSignatureAlgorithm { 
get; }
 
+                       public virtual bool 
IsAsymmetricKeyWrapAlgorithmSupported (
+                               string algorithm)
+                       {
+                               return algorithm == 
DefaultAsymmetricKeyWrapAlgorithm;
+                       }
+
                public abstract bool IsAsymmetricKeyLengthSupported (int 
length);
 
-               [MonoTODO]
-               public virtual bool IsAsymmetricKeyWrapAlgorithmSupported (
-                       string algorithm)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               [MonoTODO]
                public virtual bool IsAsymmetricSignatureAlgorithmSupported (
                        string algorithm)
                {
-                       throw new NotImplementedException ();
+                               return algorithm == 
DefaultAsymmetricSignatureAlgorithm;
                }
 
                [MonoTODO]

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs
       2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs
       2007-01-15 08:40:55 UTC (rev 71007)
@@ -28,7 +28,6 @@
 
 namespace System.ServiceModel.Security
 {
-       [MonoTODO]
        public abstract class SecurityVersion
        {
                static SecurityVersion wss10, wss11;

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
     2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
     2007-01-15 08:40:55 UTC (rev 71007)
@@ -203,7 +203,7 @@
                }
 
                [MonoTODO]
-               public SecurityKeyIdentifierClause 
CreateKeyIdentifierClauseFromTokenXml (
+               public virtual SecurityKeyIdentifierClause 
CreateKeyIdentifierClauseFromTokenXml (
                        XmlElement tokenXml, SecurityTokenReferenceStyle 
referenceStyle)
                {
                        throw new NotImplementedException ();

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
   2007-01-15 08:40:55 UTC (rev 71007)
@@ -1,3 +1,8 @@
+2007-01-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * WSSecurityTokenSerializerTest.cs: some tests for writing derived-
+         key-involved key identifier clauses.
+
 2007-01-12  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * WSSecurityTokenSerializerTest.cs : added some tests for 

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
    2007-01-15 08:37:41 UTC (rev 71006)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
    2007-01-15 08:40:55 UTC (rev 71007)
@@ -286,6 +286,27 @@
                }
 
                [Test]
+               public void WriteEncryptedKeyIdentifierClause2 () // derived key
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       SecurityKeyIdentifier cki = new SecurityKeyIdentifier 
();
+                       cki.Add (new X509ThumbprintKeyIdentifierClause (cert));
+                       EncryptedKeyIdentifierClause ic =
+                               new EncryptedKeyIdentifierClause (bytes, 
SecurityAlgorithms.Aes256KeyWrap, cki, "carriedKeyNaaaaame", new byte [32], 32);
+                       
+                       using (XmlWriter w = XmlWriter.Create (sw, 
GetWriterSettings ())) {
+                               
WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<e:EncryptedKey 
xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\" /><KeyInfo 
xmlns=\"{2}\"><o:SecurityTokenReference 
xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\";><o:KeyIdentifier
 
ValueType=\"{3}\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</e:CipherValue></e:CipherData><e:CarriedKeyName>carriedKeyNaaaaame</e:CarriedKeyName></e:EncryptedKey>",
+                               EncryptedXml.XmlEncNamespaceUrl,
+                               SecurityAlgorithms.Aes256KeyWrap,
+                               SignedXml.XmlDsigNamespaceUrl,
+                               
"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1";);
+                       Assert.AreEqual (expected, sw.ToString ());
+               }
+
+               [Test]
                public void WriteLocalIdKeyIdentifierClause1 ()
                {
                        StringWriter sw = new StringWriter ();
@@ -331,6 +352,18 @@
                }
 
                [Test]
+               [Ignore ("fails on .net; no further verification")]
+               public void WriteLocalIdKeyIdentifierClause5 () // derivedKey
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new 
LocalIdKeyIdentifierClause ("urn:myIDValue", new byte [32], 16, typeof 
(WrappedKeySecurityToken));
+                       using (XmlWriter w = XmlWriter.Create (sw, 
GetWriterSettings ())) {
+                               new WSSecurityTokenSerializer 
(true).WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference 
xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\";><o:Reference
 
ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey\";
 URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+               }
+
+               [Test]
                public void ReadKeyIdentifierClause ()
                {
                        string xml = @"<o:SecurityTokenReference 
xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>

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

Reply via email to