Author: mhabersack
Date: 2007-10-31 21:14:52 -0500 (Wed, 31 Oct 2007)
New Revision: 88621
Added:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySectionUtils.cs
Modified:
trunk/mcs/class/System.Web/ChangeLog
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySection.cs
trunk/mcs/class/System.Web/System.Web.Handlers/AssemblyResourceLoader.cs
trunk/mcs/class/System.Web/System.Web.Handlers/ChangeLog
trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
trunk/mcs/class/System.Web/System.Web.Security/MembershipProvider.cs
trunk/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
trunk/mcs/class/System.Web/System.Web.UI/Page.cs
trunk/mcs/class/System.Web/System.Web.dll.sources
Log:
2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
* Page.cs, ObjectStateFormatter.cs: use the new
MachineKeySectionUtils class wherever necessary.
2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
* System.Web.dll.sources: added MachineKeySectionUtils.cs
2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
* RolePrincipal.cs, MembershipProvider.cs: use the new
MachineKeySectionUtils class wherever necessary.
* FormsAuthentication.cs: use the new MachineKeySectionUtils class
wherever necessary.
GetHexString is a private method again.
2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
* MachineKeySection.cs: moved all the internal static methods and
properties to MachineKeySectionUtils.cs
* MachineKeySectionUtils.cs: added. This file is included in the
System.Web.Extensions compilation.
The old properties from MachineKeySection.cs became methods.
2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
* AssemblyResourceLoader.cs: added GetHexString, copied from
FormsAuthentication.cs. Encryption/decryption routines use methods
from the new MachineKeySectionUtils class. This is needed for the
same code to work from both System.Web and System.Web.Extensions.
Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog 2007-11-01 00:57:11 UTC (rev
88620)
+++ trunk/mcs/class/System.Web/ChangeLog 2007-11-01 02:14:52 UTC (rev
88621)
@@ -1,3 +1,7 @@
+2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
+
+ * System.Web.dll.sources: added MachineKeySectionUtils.cs
+
2007-10-24 Marek Habersack <[EMAIL PROTECTED]>
* System.Web.dll.sources: added
Modified: trunk/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog
2007-11-01 02:14:52 UTC (rev 88621)
@@ -1,3 +1,12 @@
+2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
+
+ * MachineKeySection.cs: moved all the internal static methods and
+ properties to MachineKeySectionUtils.cs
+
+ * MachineKeySectionUtils.cs: added. This file is included in the
+ System.Web.Extensions compilation.
+ The old properties from MachineKeySection.cs became methods.
+
2007-10-24 Marek Habersack <[EMAIL PROTECTED]>
* HttpHandlerAction.cs: exact path matching must be done on the
Modified:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySection.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySection.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySection.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -71,7 +71,7 @@
properties.Add (validationProp);
properties.Add (validationKeyProp);
- AutoGenKeys ();
+ MachineKeySectionUtils.AutoGenKeys ();
}
protected override void Reset (ConfigurationElement
parentElement)
@@ -92,7 +92,10 @@
[ConfigurationProperty ("decryptionKey", DefaultValue =
"AutoGenerate,IsolateApps")]
public string DecryptionKey {
get { return (string) base [decryptionKeyProp];}
- set { base[decryptionKeyProp] = value;
SetDecryptionKey (value); }
+ set {
+ base[decryptionKeyProp] = value;
+ MachineKeySectionUtils.SetDecryptionKey (value);
+ }
}
[TypeConverter (typeof (MachineKeyValidationConverter))]
@@ -107,123 +110,15 @@
[ConfigurationProperty ("validationKey", DefaultValue =
"AutoGenerate,IsolateApps")]
public string ValidationKey {
get { return (string) base [validationKeyProp];}
- set { base[validationKeyProp] = value;
SetValidationKey (value); }
+ set {
+ base[validationKeyProp] = value;
+ MachineKeySectionUtils.SetValidationKey (value);
+ }
}
protected override ConfigurationPropertyCollection Properties {
get { return properties; }
}
-
-#region CompatabilityCode
- static byte [] autogenerated;
- static byte [] autogenerated_decrypt;
- byte[] decryption_key;
- byte[] decryption_key_192bits;
- byte[] validation_key;
-
- static void AutoGenKeys ()
- {
-#if TARGET_J2EE
- {
-#else
- try {
- autogenerated =
MachineKeyRegistryStorage.Retrieve
(MachineKeyRegistryStorage.KeyType.Validation);
- autogenerated_decrypt =
MachineKeyRegistryStorage.Retrieve
(MachineKeyRegistryStorage.KeyType.Encryption);
- } catch (Exception) {
-#endif
- // Fall back to old method
- autogenerated = new byte [64];
- RandomNumberGenerator rng =
RandomNumberGenerator.Create ();
- rng.GetBytes (autogenerated);
- autogenerated_decrypt = new byte [64];
- rng.GetBytes (autogenerated_decrypt);
- }
- }
-
- static byte ToHexValue (char c, bool high)
- {
- byte v;
- if (c >= '0' && c <= '9')
- v = (byte) (c - '0');
- else if (c >= 'a' && c <= 'f')
- v = (byte) (c - 'a' + 10);
- else if (c >= 'A' && c <= 'F')
- v = (byte) (c - 'A' + 10);
- else
- throw new ArgumentException ("Invalid hex
character");
-
- if (high)
- v <<= 4;
-
- return v;
- }
-
- internal static byte [] GetBytes (string key, int len)
- {
- byte [] result = new byte [len / 2];
- for (int i = 0; i < len; i += 2)
- result [i / 2] = (byte) (ToHexValue (key [i],
true) + ToHexValue (key [i + 1], false));
-
- return result;
- }
-
- static byte [] MakeKey (string key, bool decryption) //, out
bool isolate)
- {
- if (key == null || key.StartsWith ("AutoGenerate")){
- //isolate = key.IndexOf ("IsolateApps") != 1;
-
- return (decryption) ? autogenerated_decrypt :
autogenerated;
- }
-
- //isolate = false;
-
- int len = key.Length;
- if (len < 40 || len > 128 || (len % 2) == 1)
- throw new ArgumentException ("Invalid key
length");
-
- return GetBytes (key, len);
- }
-
- internal void SetDecryptionKey (string n)
- {
- decryption_key = MakeKey (n, true); //, out
isolate_decryption);
- decryption_key_192bits = new byte [24];
- int count = 24;
- if (decryption_key.Length < 24)
- count = decryption_key.Length;
- Buffer.BlockCopy (decryption_key, 0,
decryption_key_192bits, 0, count);
- }
-
- internal void SetValidationKey (string n)
- {
- validation_key = MakeKey (n, false); //, out
isolate_validation);
- }
-
- internal byte [] ValidationKeyBytes {
- get {
- if (validation_key == null)
- SetValidationKey (ValidationKey);
- return validation_key;
- }
- }
-
- internal byte [] DecryptionKeyBytes {
- get {
- if (decryption_key == null)
- SetDecryptionKey (DecryptionKey);
- return decryption_key;
- }
- }
-
- internal byte [] DecryptionKey192Bits {
- get {
- if (decryption_key_192bits == null)
- SetDecryptionKey (DecryptionKey);
- return decryption_key_192bits;
- }
- }
-#endregion
-
}
}
Added:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySectionUtils.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySectionUtils.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySectionUtils.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -0,0 +1,177 @@
+//
+// System.Web.Configuration.MachineKeySection
+//
+// Authors:
+// Chris Toshok ([EMAIL PROTECTED])
+//
+// (c) Copyright 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ComponentModel;
+using System.Configuration;
+using System.Security.Cryptography;
+
+#if NET_2_0
+
+namespace System.Web.Configuration {
+
+ internal static class MachineKeySectionUtils
+ {
+ static byte [] autogenerated;
+ static byte [] autogenerated_decrypt;
+ static byte[] decryption_key;
+ static byte[] decryption_key_192bits;
+ static byte[] validation_key;
+
+ internal static void AutoGenKeys ()
+ {
+#if TARGET_J2EE
+ {
+#else
+ try {
+ autogenerated =
MachineKeyRegistryStorage.Retrieve
(MachineKeyRegistryStorage.KeyType.Validation);
+ autogenerated_decrypt =
MachineKeyRegistryStorage.Retrieve
(MachineKeyRegistryStorage.KeyType.Encryption);
+ } catch (Exception) {
+#endif
+ // Fall back to old method
+ autogenerated = new byte [64];
+ RandomNumberGenerator rng =
RandomNumberGenerator.Create ();
+ rng.GetBytes (autogenerated);
+ autogenerated_decrypt = new byte [64];
+ rng.GetBytes (autogenerated_decrypt);
+ }
+ }
+
+ static byte ToHexValue (char c, bool high)
+ {
+ byte v;
+ if (c >= '0' && c <= '9')
+ v = (byte) (c - '0');
+ else if (c >= 'a' && c <= 'f')
+ v = (byte) (c - 'a' + 10);
+ else if (c >= 'A' && c <= 'F')
+ v = (byte) (c - 'A' + 10);
+ else
+ throw new ArgumentException ("Invalid hex
character");
+
+ if (high)
+ v <<= 4;
+
+ return v;
+ }
+
+ internal static byte [] GetBytes (string key, int len)
+ {
+ byte [] result = new byte [len / 2];
+ for (int i = 0; i < len; i += 2)
+ result [i / 2] = (byte) (ToHexValue (key [i],
true) + ToHexValue (key [i + 1], false));
+
+ return result;
+ }
+
+ static byte [] MakeKey (string key, bool decryption) //, out
bool isolate)
+ {
+ if (key == null || key.StartsWith ("AutoGenerate")){
+ //isolate = key.IndexOf ("IsolateApps") != 1;
+
+ return (decryption) ? autogenerated_decrypt :
autogenerated;
+ }
+
+ //isolate = false;
+
+ int len = key.Length;
+ if (len < 40 || len > 128 || (len % 2) == 1)
+ throw new ArgumentException ("Invalid key
length");
+
+ return GetBytes (key, len);
+ }
+
+ internal static void SetDecryptionKey (string n)
+ {
+ decryption_key = MakeKey (n, true); //, out
isolate_decryption);
+ decryption_key_192bits = new byte [24];
+ int count = 24;
+ if (decryption_key.Length < 24)
+ count = decryption_key.Length;
+ Buffer.BlockCopy (decryption_key, 0,
decryption_key_192bits, 0, count);
+ }
+
+ internal static void SetValidationKey (string n)
+ {
+ validation_key = MakeKey (n, false); //, out
isolate_validation);
+ }
+
+ static MachineKeySection Config {
+ get { return WebConfigurationManager.GetSection
("system.web/machineKey") as MachineKeySection; }
+ }
+
+ internal static byte [] ValidationKeyBytes ()
+ {
+ return ValidationKeyBytes (Config);
+ }
+
+ internal static byte [] ValidationKeyBytes (MachineKeySection
section)
+ {
+ if (section == null)
+ throw new ArgumentNullException ("section");
+
+ if (validation_key == null)
+ SetValidationKey (section.ValidationKey);
+ return validation_key;
+ }
+
+ internal static byte [] DecryptionKeyBytes ()
+ {
+ return DecryptionKeyBytes (Config);
+ }
+
+ internal static byte [] DecryptionKeyBytes (MachineKeySection
section)
+ {
+ if (section == null)
+ throw new ArgumentNullException ("section");
+
+ if (decryption_key == null)
+ SetDecryptionKey (section.DecryptionKey);
+ return decryption_key;
+ }
+
+ internal static byte [] DecryptionKey192Bits ()
+ {
+ return DecryptionKey192Bits (Config);
+ }
+
+ internal static byte [] DecryptionKey192Bits (MachineKeySection
section)
+ {
+ if (section == null)
+ throw new ArgumentNullException ("section");
+
+ if (decryption_key_192bits == null)
+ SetDecryptionKey (section.DecryptionKey);
+ return decryption_key_192bits;
+ }
+ }
+}
+
+#endif
Property changes on:
trunk/mcs/class/System.Web/System.Web.Configuration_2.0/MachineKeySectionUtils.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
trunk/mcs/class/System.Web/System.Web.Handlers/AssemblyResourceLoader.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Handlers/AssemblyResourceLoader.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Handlers/AssemblyResourceLoader.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -88,16 +88,40 @@
return (url != null) ? url : GetResourceUrl (assembly,
resourceName, false);
}
+ static string GetHexString (byte [] bytes)
+ {
+ const int letterPart = 55;
+ const int numberPart = 48;
+ char [] result = new char [bytes.Length * 2];
+ for (int i = 0; i < bytes.Length; i++) {
+ int tmp = (int) bytes [i];
+ int second = tmp & 15;
+ int first = (tmp >> 4) & 15;
+ result [(i * 2)] = (char) (first > 9 ?
letterPart + first : numberPart + first);
+ result [(i * 2) + 1] = (char) (second > 9 ?
letterPart + second : numberPart + second);
+ }
+ return new string (result);
+ }
+
static byte[] GetEncryptionKey ()
{
#if NET_2_0
- MachineKeySection config =
WebConfigurationManager.GetSection ("system.web/machineKey") as
MachineKeySection;
+ return MachineKeySectionUtils.DecryptionKey192Bits ();
#else
MachineKeyConfig config = HttpContext.GetAppConfig
("system.web/machineKey") as MachineKeyConfig;
+ return config.DecryptionKey192Bits;
#endif
- return config.DecryptionKey192Bits;
}
+ static byte[] GetBytes (string val)
+ {
+#if NET_2_0
+ return MachineKeySectionUtils.GetBytes (val,
val.Length);
+#else
+ return MachineKeyConfig.GetBytes (val, val.Length);
+#endif
+ }
+
static byte [] init_vector = { 0xD, 0xE, 0xA, 0xD, 0xB, 0xE,
0xE, 0xF };
static string EncryptAssemblyResource (string asmName, string
resName)
@@ -107,28 +131,21 @@
string result;
ICryptoTransform encryptor = TripleDES.Create
().CreateEncryptor (key, init_vector);
- result =
System.Web.Security.FormsAuthentication.GetHexString (
- encryptor.TransformFinalBlock (bytes, 0,
bytes.Length)
- );
+ result = GetHexString (encryptor.TransformFinalBlock
(bytes, 0, bytes.Length));
bytes = null;
- return result.ToLower (CultureInfo.InvariantCulture);
+ return String.Format ("d={0}", result.ToLower
(CultureInfo.InvariantCulture));
}
static void DecryptAssemblyResource (string val, out string
asmName, out string resName)
{
byte[] key = GetEncryptionKey ();
- byte[] bytes;
+ byte[] bytes = GetBytes (val);
byte[] result;
asmName = null;
- resName = null;
-
-#if NET_2_0
- bytes = MachineKeySection.GetBytes (val, val.Length);
-#else
- bytes = MachineKeyConfig.GetBytes (val, val.Length);
-#endif
+ resName = null;
+
ICryptoTransform decryptor = TripleDES.Create
().CreateDecryptor (key, init_vector);
result = decryptor.TransformFinalBlock (bytes, 0,
bytes.Length);
bytes = null;
@@ -160,7 +177,7 @@
if (apath != String.Empty)
atime = String.Format ("{0}t={1}",
QueryParamSeparator, File.GetLastWriteTimeUtc (apath).Ticks);
#endif
- string href = String.Format ("{0}?d={1}{2}{3}",
HandlerFileName,
+ string href = String.Format ("{0}?{1}{2}{3}",
HandlerFileName,
EncryptAssemblyResource
(aname, resourceName), atime, extra);
HttpContext ctx = HttpContext.Current;
Modified: trunk/mcs/class/System.Web/System.Web.Handlers/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Handlers/ChangeLog 2007-11-01
00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Handlers/ChangeLog 2007-11-01
02:14:52 UTC (rev 88621)
@@ -1,3 +1,10 @@
+2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
+
+ * AssemblyResourceLoader.cs: added GetHexString, copied from
+ FormsAuthentication.cs. Encryption/decryption routines use methods
+ from the new MachineKeySectionUtils class. This is needed for the
+ same code to work from both System.Web and System.Web.Extensions.
+
2007-10-31 Marek Habersack <[EMAIL PROTECTED]>
* AssemblyResourceLoader.cs: implemented assembly+resource name
Modified: trunk/mcs/class/System.Web/System.Web.Security/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/ChangeLog 2007-11-01
00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Security/ChangeLog 2007-11-01
02:14:52 UTC (rev 88621)
@@ -1,3 +1,12 @@
+2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
+
+ * RolePrincipal.cs, MembershipProvider.cs: use the new
+ MachineKeySectionUtils class wherever necessary.
+
+ * FormsAuthentication.cs: use the new MachineKeySectionUtils class
+ wherever necessary.
+ GetHexString is a private method again.
+
2007-10-31 Marek Habersack <[EMAIL PROTECTED]>
* FormsAuthentication.cs: made GetHexString an internal method -
Modified: trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Security/FormsAuthentication.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -235,6 +235,18 @@
return (password == stored);
}
+#if NET_2_0
+ static byte [] GetDecryptionKey (MachineKeySection config)
+ {
+ return MachineKeySectionUtils.DecryptionKey192Bits
(config);
+ }
+#else
+ static byte [] GetDecryptionKey (MachineKeyConfig config)
+ {
+ return config.DecryptionKey192Bits;
+ }
+#endif
+
static FormsAuthenticationTicket Decrypt2 (byte [] bytes)
{
if (protection == FormsProtectionEnum.None)
@@ -250,7 +262,7 @@
byte [] result = bytes;
if (all || protection ==
FormsProtectionEnum.Encryption) {
ICryptoTransform decryptor;
- decryptor = TripleDES.Create ().CreateDecryptor
(config.DecryptionKey192Bits, init_vector);
+ decryptor = TripleDES.Create ().CreateDecryptor
(GetDecryptionKey (config), init_vector);
result = decryptor.TransformFinalBlock (bytes,
0, bytes.Length);
bytes = null;
}
@@ -270,7 +282,7 @@
count = SHA1_hash_size; // 3DES and SHA1
#if NET_2_0
- byte [] vk = config.ValidationKeyBytes;
+ byte [] vk =
MachineKeySectionUtils.ValidationKeyBytes (config);
#else
byte [] vk = config.ValidationKey;
#endif
@@ -312,7 +324,7 @@
FormsAuthenticationTicket ticket;
#if NET_2_0
- byte [] bytes = MachineKeySection.GetBytes
(encryptedTicket, encryptedTicket.Length);
+ byte [] bytes = MachineKeySectionUtils.GetBytes
(encryptedTicket, encryptedTicket.Length);
#else
byte [] bytes = MachineKeyConfig.GetBytes
(encryptedTicket, encryptedTicket.Length);
#endif
@@ -345,7 +357,7 @@
if (all || protection ==
FormsProtectionEnum.Validation) {
byte [] valid_bytes = null;
#if NET_2_0
- byte [] vk = config.ValidationKeyBytes;
+ byte [] vk =
MachineKeySectionUtils.ValidationKeyBytes (config);
#else
byte [] vk = config.ValidationKey;
#endif
@@ -379,7 +391,7 @@
if (all || protection ==
FormsProtectionEnum.Encryption) {
ICryptoTransform encryptor;
- encryptor = TripleDES.Create ().CreateEncryptor
(config.DecryptionKey192Bits, init_vector);
+ encryptor = TripleDES.Create ().CreateEncryptor
(GetDecryptionKey (config), init_vector);
result = encryptor.TransformFinalBlock (result,
0, result.Length);
}
@@ -460,7 +472,7 @@
return returnUrl;
}
- internal static string GetHexString (byte [] bytes)
+ static string GetHexString (byte [] bytes)
{
const int letterPart = 55;
const int numberPart = 48;
Modified: trunk/mcs/class/System.Web/System.Web.Security/MembershipProvider.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/MembershipProvider.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Security/MembershipProvider.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -96,7 +96,7 @@
else
throw new ProviderException (String.Format
("Unsupported decryption attribute '{0}' in <machineKey> configuration
section", alg_type));
- decryptionKey = section.DecryptionKey192Bits;
+ decryptionKey =
MachineKeySectionUtils.DecryptionKey192Bits (section);
return alg;
}
Modified: trunk/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.Security/RolePrincipal.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -146,7 +146,7 @@
if (cookieProtection == CookieProtection.All ||
cookieProtection == CookieProtection.Validation) {
byte [] hashBytes = null;
- byte [] validationBytes =
MachineConfig.ValidationKeyBytes;
+ byte [] validationBytes =
MachineKeySectionUtils.ValidationKeyBytes (MachineConfig);
writer.Write (validationBytes);
switch (MachineConfig.Validation) {
@@ -167,7 +167,8 @@
byte [] ticketBytes = null;
if (cookieProtection == CookieProtection.All ||
cookieProtection == CookieProtection.Encryption) {
ICryptoTransform enc;
- enc = TripleDES.Create ().CreateEncryptor
(MachineConfig.DecryptionKey192Bits, InitVector);
+ enc = TripleDES.Create ().CreateEncryptor
(MachineKeySectionUtils.DecryptionKey192Bits (MachineConfig),
+
InitVector);
ticketBytes = enc.TransformFinalBlock
(ticket.GetBuffer (), 0, (int) ticket.Position);
}
@@ -188,14 +189,16 @@
CookieProtection cookieProtection =
RoleManagerConfig.CookieProtection;
if (cookieProtection == CookieProtection.All ||
cookieProtection == CookieProtection.Encryption) {
ICryptoTransform decryptor;
- decryptor = TripleDES.Create ().CreateDecryptor
(MachineConfig.DecryptionKey192Bits, InitVector);
+ decryptor = TripleDES.Create ().CreateDecryptor
(
+
MachineKeySectionUtils.DecryptionKey192Bits (MachineConfig),
+ InitVector);
decryptedTicketBytes =
decryptor.TransformFinalBlock (ticketBytes, 0, ticketBytes.Length);
}
else
decryptedTicketBytes = ticketBytes;
if (cookieProtection == CookieProtection.All ||
cookieProtection == CookieProtection.Validation) {
- byte [] validationBytes =
MachineConfig.ValidationKeyBytes;
+ byte [] validationBytes =
MachineKeySectionUtils.ValidationKeyBytes (MachineConfig);
byte [] rolesWithValidationBytes = null;
byte [] tmpValidation = null;
Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2007-11-01 00:57:11 UTC
(rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog 2007-11-01 02:14:52 UTC
(rev 88621)
@@ -1,3 +1,8 @@
+2007-11-01 Marek Habersack <[EMAIL PROTECTED]>
+
+ * Page.cs, ObjectStateFormatter.cs: use the new
+ MachineKeySectionUtils class wherever necessary.
+
2007-10-29 Marek Habersack <[EMAIL PROTECTED]>
* TemplateParser.cs: add the file pointed to by the Src or
Modified: trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
2007-11-01 00:57:11 UTC (rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
2007-11-01 02:14:52 UTC (rev 88621)
@@ -103,7 +103,7 @@
if (page != null) {
#if NET_2_0
MachineKeySection mconfig = (MachineKeySection)
WebConfigurationManager.GetSection ("system.web/machineKey");
- algoKey = mconfig.ValidationKeyBytes;
+ algoKey =
MachineKeySectionUtils.ValidationKeyBytes (mconfig);
#else
MachineKeyConfig mconfig =
HttpContext.GetAppConfig ("system.web/machineKey") as MachineKeyConfig;
algoKey = mconfig.ValidationKey;
Modified: trunk/mcs/class/System.Web/System.Web.UI/Page.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2007-11-01 00:57:11 UTC
(rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.UI/Page.cs 2007-11-01 02:14:52 UTC
(rev 88621)
@@ -2289,7 +2289,7 @@
{
ICryptoTransform transform = null;
MachineKeySection config = (MachineKeySection)
WebConfigurationManager.GetSection (machineKeyConfigPath);
- byte [] vk = config.ValidationKeyBytes;
+ byte [] vk = MachineKeySectionUtils.ValidationKeyBytes (config);
switch (config.Validation) {
case MachineKeyValidation.SHA1:
Modified: trunk/mcs/class/System.Web/System.Web.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web.dll.sources 2007-11-01 00:57:11 UTC
(rev 88620)
+++ trunk/mcs/class/System.Web/System.Web.dll.sources 2007-11-01 02:14:52 UTC
(rev 88621)
@@ -166,6 +166,7 @@
System.Web.Configuration_2.0/IRemoteWebConfigurationHostServer.cs
System.Web.Configuration_2.0/LowerCaseStringConverter.cs
System.Web.Configuration_2.0/MachineKeySection.cs
+System.Web.Configuration_2.0/MachineKeySectionUtils.cs
System.Web.Configuration_2.0/MachineKeyValidationConverter.cs
System.Web.Configuration_2.0/MembershipSection.cs
System.Web.Configuration_2.0/NamespaceCollection.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches