Author: atsushi
Date: 2007-02-20 20:41:09 -0500 (Tue, 20 Feb 2007)
New Revision: 73229

Modified:
   trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/ChangeLog
   
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/InMemorySymmetricSecurityKey.cs
   
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/ChangeLog
   
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/InMemorySymmetricSecurityKeyTest.cs
Log:
2007-02-21  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * InMemorySymmetricSecurityKey.cs : added some argument check.

        * InMemorySymmetricSecurityKeyTest.cs :
          more GenerateDerivedKey() tests.



Modified: 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/ChangeLog
===================================================================
--- 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/ChangeLog    
    2007-02-21 01:22:40 UTC (rev 73228)
+++ 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/ChangeLog    
    2007-02-21 01:41:09 UTC (rev 73229)
@@ -1,3 +1,7 @@
+2007-02-21  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * InMemorySymmetricSecurityKey.cs : added some argument check.
+
 2007-02-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SecurityKeyIdentifier.cs : implemented all.

Modified: 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/InMemorySymmetricSecurityKey.cs
===================================================================
--- 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/InMemorySymmetricSecurityKey.cs
  2007-02-21 01:22:40 UTC (rev 73228)
+++ 
trunk/olive/class/System.IdentityModel/System.IdentityModel.Tokens/InMemorySymmetricSecurityKey.cs
  2007-02-21 01:41:09 UTC (rev 73229)
@@ -60,6 +60,16 @@
                        string algorithm, byte [] label, byte [] nonce,
                        int derivedKeyLength, int offset)
                {
+                       if (derivedKeyLength < 0)
+                               throw new ArgumentOutOfRangeException 
("derivedKeyLength");
+                       if (offset < 0)
+                               throw new ArgumentOutOfRangeException 
("offset");
+                       if (label == null)
+                               throw new ArgumentNullException ("label");
+                       if (nonce == null)
+                               throw new ArgumentNullException ("nonce");
+                       if (algorithm != SecurityAlgorithms.Psha1KeyDerivation)
+                               throw new InvalidOperationException 
(String.Format ("Key derivation algorithm '{0}' is not supported", algorithm));
                        byte [] seed = new byte [label.Length + nonce.Length];
                        Array.Copy (label, seed, label.Length);
                        Array.Copy (nonce, 0, seed, label.Length, nonce.Length);

Modified: 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/ChangeLog
===================================================================
--- 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/ChangeLog
   2007-02-21 01:22:40 UTC (rev 73228)
+++ 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/ChangeLog
   2007-02-21 01:41:09 UTC (rev 73229)
@@ -1,3 +1,8 @@
+2007-02-21  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * InMemorySymmetricSecurityKeyTest.cs :
+         more GenerateDerivedKey() tests.
+
 2007-02-15  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SecurityKeyIdentifierTest.cs : new test.

Modified: 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/InMemorySymmetricSecurityKeyTest.cs
===================================================================
--- 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/InMemorySymmetricSecurityKeyTest.cs
 2007-02-21 01:22:40 UTC (rev 73228)
+++ 
trunk/olive/class/System.IdentityModel/Test/System.IdentityModel.Tokens/InMemorySymmetricSecurityKeyTest.cs
 2007-02-21 01:41:09 UTC (rev 73229)
@@ -167,6 +167,96 @@
                }
 
                [Test]
+               [ExpectedException (typeof (InvalidOperationException))] // not 
ArgumentNullException?
+               public void GenerateDerivedKeyNullAlgorithm ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (null, wssc_label, nonce, 
key.KeySize, 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))] // not 
ArgumentNullException?
+               public void GenerateDerivedKeyUnsupportedAlgorithm ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey ("urn:my-own-way", wssc_label, 
nonce, key.KeySize, 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GenerateDerivedKeyNullLabel ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               null, nonce, key.KeySize, 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GenerateDerivedKeyNullNonce ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               wssc_label, null, key.KeySize, 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void GenerateDerivedKeyNegativeLength ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               wssc_label, nonce, -32, 0);
+               }
+
+               [Test]
+               public void GenerateDerivedKeyUnusualLength ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               wssc_label, nonce, 5, 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void GenerateDerivedKeyNegativeOffset ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               wssc_label, nonce, -32, 0);
+               }
+
+               [Test]
+               public void GenerateDerivedKeyUnusualOffset ()
+               {
+                       Key key = new Key (raw);
+                       byte [] nonce = new byte [256];
+
+                       key.GenerateDerivedKey (
+                               SecurityAlgorithms.Psha1KeyDerivation,
+                               wssc_label, nonce, 5, 0);
+               }
+
+               [Test]
                public void IsAsymmetricAlgorithm ()
                {
                        Key key = new Key (raw);

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

Reply via email to