Przeglądaj źródła

2004-02-10 Tim Coleman <[email protected]>
* DataReference.cs EncryptedKey.cs EncryptedXml.cs
* KeyInfoEncryptedKey.cs KeyReference.cs ReferenceList.cs
* X509IssuerSerial.cs XmlDecryptionTransform.cs:
Add new classes for Xml Encryption in 1.2
* CipherData.cs CipherReference.cs EncryptedData.cs
* EncryptedReference.cs EncryptionMethod.cs EncryptionProperty.cs :
Change NamespaceURI reference to EncryptedXml class.
Make compliant with 1.2
* XmlEncryption.cs:
Add new entity names.

svn path=/trunk/mcs/; revision=22962

Tim Coleman 22 lat temu
rodzic
commit
da4f97eae4

+ 13 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/ChangeLog

@@ -1,3 +1,16 @@
+2004-02-10  Tim Coleman <[email protected]>
+	* DataReference.cs EncryptedKey.cs EncryptedXml.cs
+	* KeyInfoEncryptedKey.cs KeyReference.cs ReferenceList.cs
+	* X509IssuerSerial.cs XmlDecryptionTransform.cs:
+		Add new classes for Xml Encryption in 1.2
+	* CipherData.cs CipherReference.cs EncryptedData.cs
+	* EncryptedReference.cs EncryptionMethod.cs EncryptionProperty.cs :
+		Change NamespaceURI reference to EncryptedXml class.
+		Make compliant with 1.2
+	* XmlEncryption.cs:
+		Add new entity names.
+
+
 2004-02-07  Tim Coleman <[email protected]>
 	* CipherData.cs CipherReference.cs EncryptedData.cs
 	* EncryptedReference.cs EncryptedType.cs EncryptionMethod.cs

+ 3 - 3
mcs/class/System.Security/System.Security.Cryptography.Xml/CipherData.cs

@@ -75,12 +75,12 @@ namespace System.Security.Cryptography.Xml {
 			if (CipherReference == null && CipherValue == null)
 				throw new CryptographicException ("A Cipher Data element should have either a CipherValue or a CipherReference element.");
 
-			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.CipherData, XmlEncryption.NamespaceURI);
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.CipherData, EncryptedXml.XmlEncNamespaceUrl);
 			if (CipherReference != null) 
 				xel.AppendChild (document.ImportNode (cipherReference.GetXml (), true));
 
 			if (CipherValue != null) {
-				XmlElement xcv = document.CreateElement (XmlEncryption.ElementNames.CipherValue, XmlEncryption.NamespaceURI);
+				XmlElement xcv = document.CreateElement (XmlEncryption.ElementNames.CipherValue, EncryptedXml.XmlEncNamespaceUrl);
 				StreamReader reader = new StreamReader (new CryptoStream (new MemoryStream (cipherValue), new ToBase64Transform (), CryptoStreamMode.Read));
 				xcv.InnerText = reader.ReadToEnd ();
 				reader.Close ();
@@ -97,7 +97,7 @@ namespace System.Security.Cryptography.Xml {
 			if (value == null)
 				throw new ArgumentNullException ("value");
 
-			if ((value.LocalName != XmlEncryption.ElementNames.CipherData) || (value.NamespaceURI != XmlEncryption.NamespaceURI)) 
+			if ((value.LocalName != XmlEncryption.ElementNames.CipherData) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl)) 
 				throw new CryptographicException ("Malformed Cipher Data element.");
 			else {
 				foreach (XmlNode n in value.ChildNodes) {

+ 3 - 3
mcs/class/System.Security/System.Security.Cryptography.Xml/CipherReference.cs

@@ -42,12 +42,12 @@ namespace System.Security.Cryptography.Xml {
 
 		internal override XmlElement GetXml (XmlDocument document)
 		{
-			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.CipherReference, XmlEncryption.NamespaceURI);
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.CipherReference, EncryptedXml.XmlEncNamespaceUrl);
 
 			xel.SetAttribute (XmlEncryption.AttributeNames.URI, Uri);
 
 			if (TransformChain != null && TransformChain.Count > 0) {
-				XmlElement xtr = document.CreateElement (XmlEncryption.ElementNames.Transforms, XmlEncryption.NamespaceURI);
+				XmlElement xtr = document.CreateElement (XmlEncryption.ElementNames.Transforms, EncryptedXml.XmlEncNamespaceUrl);
 				foreach (Transform t in TransformChain) 
 					xtr.AppendChild (document.ImportNode (t.GetXml (), true));
 				xel.AppendChild (xtr);
@@ -60,7 +60,7 @@ namespace System.Security.Cryptography.Xml {
 		{
 			if (value == null)
 				throw new ArgumentNullException ("value");
-			if ((value.LocalName != XmlEncryption.ElementNames.CipherReference) || (value.NamespaceURI != XmlEncryption.NamespaceURI))
+			if ((value.LocalName != XmlEncryption.ElementNames.CipherReference) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
 				throw new CryptographicException ("Malformed CipherReference element.");
 			else {
 				Uri = null;

+ 41 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/DataReference.cs

@@ -0,0 +1,41 @@
+//
+// DataReference.cs - DataReference implementation for XML Encryption
+// http://www.w3.org/2001/04/xmlenc#sec-ReferenceList
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public sealed class DataReference : EncryptedReference {
+
+		#region Constructors
+	
+		public DataReference ()
+			: base ()
+		{
+			ReferenceType = XmlEncryption.ElementNames.DataReference;
+		}
+	
+		public DataReference (string uri)
+			: base (uri)
+		{
+			ReferenceType = XmlEncryption.ElementNames.DataReference;
+		}
+	
+		public DataReference (string uri, TransformChain tc)
+			: base (uri, tc)
+		{
+			ReferenceType = XmlEncryption.ElementNames.DataReference;
+		}
+	
+		#endregion // Constructors
+	}
+}
+
+#endif

+ 4 - 4
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptedData.cs

@@ -35,7 +35,7 @@ namespace System.Security.Cryptography.Xml {
 			if (CipherData == null)
 				throw new CryptographicException ("Cipher data is not specified.");
 
-			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptedData, XmlEncryption.NamespaceURI);
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptedData, EncryptedXml.XmlEncNamespaceUrl);
 
 			if (EncryptionMethod != null)
 				xel.AppendChild (EncryptionMethod.GetXml (document));
@@ -45,7 +45,7 @@ namespace System.Security.Cryptography.Xml {
 				xel.AppendChild (CipherData.GetXml (document));
 
 			if (EncryptionProperties.Count > 0) {
-				XmlElement xep = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperties, XmlEncryption.NamespaceURI);
+				XmlElement xep = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperties, EncryptedXml.XmlEncNamespaceUrl);
 				foreach (EncryptionProperty p in EncryptionProperties)
 					xep.AppendChild (p.GetXml (document));
 				xel.AppendChild (xep);
@@ -67,7 +67,7 @@ namespace System.Security.Cryptography.Xml {
 			if (value == null)
 				throw new ArgumentNullException ("value");
 
-			if ((value.LocalName != XmlEncryption.ElementNames.EncryptedData) || (value.NamespaceURI != XmlEncryption.NamespaceURI))
+			if ((value.LocalName != XmlEncryption.ElementNames.EncryptedData) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
 				throw new CryptographicException ("Malformed EncryptedData element.");
 			else {
 				EncryptionMethod = null;
@@ -98,7 +98,7 @@ namespace System.Security.Cryptography.Xml {
 						CipherData.LoadXml ((XmlElement) n);
 						break;
 					case XmlEncryption.ElementNames.EncryptionProperties:
-						foreach (XmlElement element in ((XmlElement) n).GetElementsByTagName (XmlEncryption.ElementNames.EncryptionProperty, XmlEncryption.NamespaceURI))
+						foreach (XmlElement element in ((XmlElement) n).GetElementsByTagName (XmlEncryption.ElementNames.EncryptionProperty, EncryptedXml.XmlEncNamespaceUrl))
 							EncryptionProperties.Add (new EncryptionProperty (element));
 						break;
 					}

+ 204 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptedKey.cs

@@ -0,0 +1,204 @@
+//
+// EncryptedKey.cs - EncryptedKey implementation for XML Encryption
+// http://www.w3.org/2001/04/xmlenc#sec-EncryptedKey
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public sealed class EncryptedKey : EncryptedType {
+
+		#region Fields
+
+		string carriedKeyName;
+		string recipient;
+		ReferenceList referenceList;
+
+		#endregion // Fields
+
+		#region Constructors
+
+		public EncryptedKey ()
+			: base ()
+		{
+			CarriedKeyName = null;
+			Recipient = null;
+			ReferenceList = new ReferenceList ();
+		}
+
+		#endregion // Constructors
+
+		#region Properties
+
+		public string CarriedKeyName {
+			get { return carriedKeyName; }
+			set { carriedKeyName = value; }
+		}
+
+		public string Recipient {
+			get { return recipient; }
+			set { recipient = value; }
+		}
+
+		public ReferenceList ReferenceList {
+			get { return referenceList; }
+			set { referenceList = value; }
+		}
+
+		#endregion // Properties
+
+		#region Methods
+
+		public void AddReference (DataReference dataReference)
+		{
+			ReferenceList.Add (dataReference);
+		}
+
+		public void AddReference (KeyReference keyReference)
+		{
+			ReferenceList.Add (keyReference);
+		}
+
+		public override XmlElement GetXml ()
+		{
+			return GetXml (new XmlDocument ());
+		}
+
+		internal XmlElement GetXml (XmlDocument document)
+		{
+			if (CipherData == null)
+				throw new CryptographicException ("Cipher data is not specified.");
+
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptedData, EncryptedXml.XmlEncNamespaceUrl);
+
+			if (EncryptionMethod != null)
+				xel.AppendChild (EncryptionMethod.GetXml (document));
+			if (KeyInfo != null) 
+				xel.AppendChild (document.ImportNode (KeyInfo.GetXml (), true));
+			if (CipherData != null)
+				xel.AppendChild (CipherData.GetXml (document));
+
+			if (EncryptionProperties.Count > 0) {
+				XmlElement xep = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperties, EncryptedXml.XmlEncNamespaceUrl);
+				foreach (EncryptionProperty p in EncryptionProperties)
+					xep.AppendChild (p.GetXml (document));
+				xel.AppendChild (xep);
+			}
+
+			if (ReferenceList.Count > 0) {
+				XmlElement xrl = document.CreateElement (XmlEncryption.ElementNames.ReferenceList, EncryptedXml.XmlEncNamespaceUrl);
+				foreach (EncryptedReference er in ReferenceList) 
+					xrl.AppendChild (er.GetXml (document));
+				xel.AppendChild (xrl);
+			}
+
+			if (CarriedKeyName != null) {
+				XmlElement xck = document.CreateElement (XmlEncryption.ElementNames.CarriedKeyName, EncryptedXml.XmlEncNamespaceUrl);
+				xck.InnerText = CarriedKeyName;
+				xel.AppendChild (xck);
+			}
+
+			if (Id != null)
+				xel.SetAttribute (XmlEncryption.AttributeNames.Id, Id);
+			if (Type != null)
+				xel.SetAttribute (XmlEncryption.AttributeNames.Type, Type);
+			if (MimeType != null)
+				xel.SetAttribute (XmlEncryption.AttributeNames.MimeType, MimeType);
+			if (Encoding != null)
+				xel.SetAttribute (XmlEncryption.AttributeNames.Encoding, Encoding);
+			if (Recipient != null)
+				xel.SetAttribute (XmlEncryption.AttributeNames.Recipient, Recipient);
+			return xel;
+		}
+
+		public override void LoadXml (XmlElement value)
+		{
+			if (value == null)
+				throw new ArgumentNullException ("value");
+
+			if ((value.LocalName != XmlEncryption.ElementNames.EncryptedKey) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
+				throw new CryptographicException ("Malformed EncryptedKey element.");
+			else {
+				EncryptionMethod = null;
+				KeyInfo keyInfo = null;
+				CipherData cipherData = null;
+				EncryptionMethod = null;
+				EncryptionProperties = new EncryptionProperties ();
+				ReferenceList = new ReferenceList ();
+				CarriedKeyName = null;
+				Id = null;
+				Type = null;
+				MimeType = null;
+				Encoding = null;
+				Recipient = null;
+
+				foreach (XmlNode n in value.ChildNodes) {
+					if (n is XmlWhitespace)
+						continue;
+
+					switch (n.LocalName) {
+					case XmlEncryption.ElementNames.EncryptionMethod:
+						EncryptionMethod = new EncryptionMethod ();
+						EncryptionMethod.LoadXml ((XmlElement) n);
+						break;
+					case XmlSignature.ElementNames.KeyInfo:
+						KeyInfo = new KeyInfo ();
+						KeyInfo.LoadXml ((XmlElement) n);
+						break;
+					case XmlEncryption.ElementNames.CipherData:
+						CipherData = new CipherData ();
+						CipherData.LoadXml ((XmlElement) n);
+						break;
+					case XmlEncryption.ElementNames.EncryptionProperties:
+						foreach (XmlElement element in ((XmlElement) n).GetElementsByTagName (XmlEncryption.ElementNames.EncryptionProperty, EncryptedXml.XmlEncNamespaceUrl))
+							EncryptionProperties.Add (new EncryptionProperty (element));
+						break;
+					case XmlEncryption.ElementNames.ReferenceList:
+						foreach (XmlNode r in ((XmlElement) n).ChildNodes) {
+							if (child is XmlWhitespace) 
+								continue;
+
+							switch (child.LocalName) {
+							case XmlEncryption.ElementNames.DataReference:
+								DataReference dr = new DataReference ();
+								dr.LoadXml ((XmlElement) r);
+								AddReference (dr);
+								break;
+							case XmlEncryption.ElementNames.KeyReference:
+								KeyReference kr = new KeyReference ();
+								kr.LoadXml ((XmlElement) r);
+								AddReference (kr);
+								break;
+							}
+						}
+						break;
+					case XmlEncryption.ElementNames.CarriedKeyName:
+						CarriedKeyName = ((XmlElement) n).InnerText;
+						break;
+					}
+				}
+
+				if (value.HasAttribute (XmlEncryption.AttributeNames.Id))
+					Id = value.Attributes [XmlEncryption.AttributeNames.Id].Value;
+				if (value.HasAttribute (XmlEncryption.AttributeNames.Type))
+					Type = value.Attributes [XmlEncryption.AttributeNames.Type].Value;
+				if (value.HasAttribute (XmlEncryption.AttributeNames.MimeType))
+					MimeType = value.Attributes [XmlEncryption.AttributeNames.MimeType].Value;
+				if (value.HasAttribute (XmlEncryption.AttributeNames.Encoding))
+					Encoding = value.Attributes [XmlEncryption.AttributeNames.Encoding].Value;
+				if (value.HasAttribute (XmlEncryption.AttributeNames.Recipient))
+					Encoding = value.Attributes [XmlEncryption.AttributeNames.Recipient].Value;
+			}
+		}
+
+		#endregion // Methods
+	}
+}
+
+#endif

+ 63 - 2
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptedReference.cs

@@ -53,9 +53,9 @@ namespace System.Security.Cryptography.Xml {
 			get { return cacheValid; }
 		}
 
-		[MonoTODO]
 		protected string ReferenceType {
 			get { return referenceType; }
+			set { referenceType = value; }
 		}
 
 		public TransformChain TransformChain {
@@ -84,11 +84,72 @@ namespace System.Security.Cryptography.Xml {
 
 		internal virtual XmlElement GetXml (XmlDocument document)
 		{
-			return document.CreateElement ("", "");
+			XmlElement xel = document.CreateElement (ReferenceType, EncryptedXml.XmlEncNamespaceUrl);
+
+			xel.SetAttribute (XmlEncryption.AttributeNames.URI, Uri);
+
+                        if (TransformChain != null && TransformChain.Count > 0) {
+                                XmlElement xtr = document.CreateElement (XmlEncryption.ElementNames.Transforms, EncryptedXml.XmlEncNamespaceUrl);
+                                foreach (Transform t in TransformChain)
+                                        xtr.AppendChild (document.ImportNode (t.GetXml (), true));
+                                xel.AppendChild (xtr);
+                        }
+
+			return xel;
 		}
 
+		[MonoTODO ("Make compliant.")]
 		public virtual void LoadXml (XmlElement value)
 		{
+			if (value == null)
+				throw new ArgumentNullException ("value");
+			if ((value.LocalName != XmlEncryption.ElementNames.CipherReference) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
+				throw new CryptographicException ("Malformed CipherReference element.");
+			else {
+				Uri = null;
+				TransformChain = new TransformChain ();
+
+				foreach (XmlNode n in value.ChildNodes) {
+					if (n is XmlWhitespace)
+						continue;
+
+					switch (n.LocalName) {
+					case XmlEncryption.ElementNames.Transforms:
+						foreach (XmlNode xn in ((XmlElement) n).GetElementsByTagName (XmlSignature.ElementNames.Transform, XmlSignature.NamespaceURI)) {
+							Transform t = null;
+							switch (((XmlElement) xn).Attributes [XmlSignature.AttributeNames.Algorithm].Value) {
+							case XmlSignature.AlgorithmNamespaces.XmlDsigBase64Transform:
+								t = new XmlDsigBase64Transform ();
+								break;
+							case XmlSignature.AlgorithmNamespaces.XmlDsigC14NTransform:
+								t = new XmlDsigC14NTransform ();
+								break;
+							case XmlSignature.AlgorithmNamespaces.XmlDsigC14NWithCommentsTransform:
+								t = new XmlDsigC14NWithCommentsTransform ();
+								break;
+							case XmlSignature.AlgorithmNamespaces.XmlDsigEnvelopedSignatureTransform:
+								t = new XmlDsigEnvelopedSignatureTransform ();
+								break;
+							case XmlSignature.AlgorithmNamespaces.XmlDsigXPathTransform:
+								t = new XmlDsigXPathTransform ();
+								break;
+							case XmlSignature.AlgorithmNamespaces.XmlDsigXsltTransform:
+								t = new XmlDsigXsltTransform ();
+								break;
+							default:
+								continue;
+							}
+
+							t.LoadInnerXml (((XmlElement) xn).ChildNodes);
+							TransformChain.Add (t);
+						}
+						break;
+					}
+				}
+
+				if (value.HasAttribute (XmlEncryption.AttributeNames.URI))
+					Uri = value.Attributes [XmlEncryption.AttributeNames.URI].Value;
+			}
 		}
 
 		#endregion // Methods

+ 196 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptedXml.cs

@@ -0,0 +1,196 @@
+//
+// EncryptedXml.cs - EncryptedXml implementation for XML Encryption
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Collections;
+using System.Security.Policy;
+using System.Text;
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public class EncryptedXml {
+
+		#region Fields
+
+		public const string XmlEncAES128KeyWrapUrl	= XmlEncNamespaceUrl + "kw-aes128";
+		public const string XmlEncAES128Url		= XmlEncNamespaceUrl + "aes128-cbc";
+		public const string XmlEncAES192KeyWrapUrl	= XmlEncNamespaceUrl + "kw-aes192";
+		public const string XmlEncAES192Url		= XmlEncNamespaceUrl + "aes192-cbc";
+		public const string XmlEncAES256KeyWrapUrl	= XmlEncNamespaceUrl + "kw-aes256";
+		public const string XmlEncAES256Url		= XmlEncNamespaceUrl + "aes256-cbc";
+		public const string XmlEncDESUrl		= XmlEncNamespaceUrl + "des-cbc";
+		public const string XmlEncElementContentUrl	= XmlEncNamespaceUrl + "ElementContent";
+		public const string XmlEncElementUrl		= XmlEncNamespaceUrl + "element";
+		public const string XmlEncEncryptedKeyUrl	= XmlEncNamespaceUrl + "EncryptedKey";
+		public const string XmlEncNamespaceUrl		= "http://www.w3.org/2001/04/xmlenc#";
+		public const string XmlEncRSA1_5Url		= XmlEncNamespaceUrl + "rsa-1_5";
+		public const string XmlEncRSAOAEPUrl		= XmlEncNamespaceUrl + "rsa-oaep-mgf1p";
+		public const string XmlEncSHA256Url		= XmlEncNamespaceUrl + "sha256";
+		public const string XmlEncSHA512Url		= XmlEncNamespaceUrl + "sha512";
+		public const string XmlEncTripleDESKeyWrapUrl	= XmlEncNamespaceUrl + "kw-tripledes";
+		public const string XmlEncTripleDESUrl		= XmlEncNamespaceUrl + "tripledes-cbc";
+
+		Evidence documentEvidence;
+		Encoding encoding = Encoding.UTF8;
+		Hashtable keyNameMapping = new Hashtable ();
+		CipherMode mode = CipherMode.CBC;
+		PaddingMode padding = PaddingMode.ISO10126;
+		string recipient;
+		XmlResolver resolver;
+
+		#endregion // Fields
+	
+		#region Constructors
+
+		[MonoTODO]
+		public EncryptedXml ()
+		{
+		}
+
+		[MonoTODO]
+		public EncryptedXml (XmlDocument document)
+		{
+		}
+
+		[MonoTODO]
+		public EncryptedXml (XmlDocument document, Evidence evidence)
+		{
+			DocumentEvidence = evidence;
+		}
+	
+		#endregion // Constructors
+	
+		#region Properties
+
+		public Evidence DocumentEvidence {
+			get { return documentEvidence; }
+			set { documentEvidence = value; }
+		}
+
+		public Encoding Encoding {
+			get { return encoding; }
+			set { encoding = value; }
+		}
+
+		public CipherMode Mode {
+			get { return mode; }
+			set { mode = value; }
+		}
+
+		public PaddingMode Padding {
+			get { return padding; }
+			set { padding = value; }
+		}
+
+		public string Recipient {
+			get { return recipient; }
+			set { recipient = value; }
+		}
+		
+		public XmlResolver Resolver {
+			get { return resolver; }
+			set { resolver = value; }
+		}
+
+		#endregion // Properties
+
+		#region Methods
+
+		public void AddKeyNameMapping (string keyName, object keyObject)
+		{
+			keyNameMapping [keyName] = keyObject;
+		}
+
+		public void ClearKeyNameMappings ()
+		{
+			keyNameMapping.Clear ();
+		}
+
+		[MonoTODO]
+		public byte[] DecryptData (EncryptedData encryptedData, SymmetricAlgorithm symAlg)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public void DecryptDocument ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual byte[] DecryptEncryptedKey (EncryptedKey encryptedKey)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static byte[] DecryptKey (byte[] keyData, SymmetricAlgorithm symAlg)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static byte[] DecryptKey (byte[] keyData, RSA rsa, bool fOAEP)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public byte[] EncryptData (XmlElement inputElement, SymmetricAlgorithm symAlg, bool content)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static byte[] EncryptKey (byte[] keyData, SymmetricAlgorithm symAlg)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public static byte[] EncryptKey (byte[] keyData, RSA rsa, bool fOAEP)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual byte[] GetDecryptionIV (EncryptedData encryptedData, string symAlgUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public virtual SymmetricAlgorithm GetDecryptionKey (EncryptedData encryptedData, string symAlgUri)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public virtual XmlElement GetIdElement (XmlDocument document, string idValue)
+		{
+                        // this works only if there's a DTD or XSD available to define the ID
+			XmlElement xel = document.GetElementById (idValue);
+			if (xel == null) {
+				// search an "undefined" ID
+				xel = (XmlElement) document.SelectSingleNode ("//*[@Id='" + idValue + "']");
+			}
+			return xel;
+		}
+
+		[MonoTODO]
+		public static void ReplaceElement (XmlElement inputElement, EncryptedData encryptedData, bool content)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion // Methods
+	}
+}
+
+#endif

+ 3 - 3
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptionMethod.cs

@@ -62,10 +62,10 @@ namespace System.Security.Cryptography.Xml {
 
 		internal XmlElement GetXml (XmlDocument document)
 		{
-			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptionMethod, XmlEncryption.NamespaceURI);
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptionMethod, EncryptedXml.XmlEncNamespaceUrl);
 
 			if (KeySize != 0) {
-				XmlElement xks = document.CreateElement (XmlEncryption.ElementNames.KeySize, XmlEncryption.NamespaceURI);
+				XmlElement xks = document.CreateElement (XmlEncryption.ElementNames.KeySize, EncryptedXml.XmlEncNamespaceUrl);
 				xks.InnerText = String.Format ("{0}", keySize);
 				xel.AppendChild (xks);
 			}
@@ -79,7 +79,7 @@ namespace System.Security.Cryptography.Xml {
 		{
 			if (value == null)
 				throw new ArgumentNullException ("value");
-			if ((value.LocalName != XmlEncryption.ElementNames.EncryptionMethod) || (value.NamespaceURI != XmlEncryption.NamespaceURI))
+			if ((value.LocalName != XmlEncryption.ElementNames.EncryptionMethod) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
 				throw new CryptographicException ("Malformed EncryptionMethod element.");
 			else {
 				KeyAlgorithm = null;

+ 2 - 2
mcs/class/System.Security/System.Security.Cryptography.Xml/EncryptionProperty.cs

@@ -61,7 +61,7 @@ namespace System.Security.Cryptography.Xml {
 
 		internal XmlElement GetXml (XmlDocument document)
 		{
-			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperty, XmlEncryption.NamespaceURI);
+			XmlElement xel = document.CreateElement (XmlEncryption.ElementNames.EncryptionProperty, EncryptedXml.XmlEncNamespaceUrl);
 
 			if (Id != null)
 				xel.SetAttribute (XmlEncryption.AttributeNames.Id, Id);
@@ -76,7 +76,7 @@ namespace System.Security.Cryptography.Xml {
 			if (value == null)
 				throw new ArgumentNullException ("value");
 
-			if ((value.LocalName != XmlEncryption.ElementNames.EncryptionProperty) || (value.NamespaceURI != XmlEncryption.NamespaceURI))
+			if ((value.LocalName != XmlEncryption.ElementNames.EncryptionProperty) || (value.NamespaceURI != EncryptedXml.XmlEncNamespaceUrl))
 				throw new CryptographicException ("Malformed EncryptionProperty element.");
 			else {	
 				if (value.HasAttribute (XmlEncryption.AttributeNames.Id))

+ 73 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.cs

@@ -0,0 +1,73 @@
+//
+// KeyInfoEncryptedKey.cs - KeyInfoEncryptedKey implementation for XML Encryption
+// http://www.w3.org/2001/04/xmlenc#sec-EncryptedKey
+//
+// Author:
+//     Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+//
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+
+	public class KeyInfoEncryptedKey : KeyInfoClause {
+
+		#region Fields
+
+		EncryptedKey encryptedKey;
+
+		#endregion // Fields
+
+		#region Constructors
+
+		public KeyInfoEncryptedKey ()
+		{
+		}
+
+		public KeyInfoEncryptedKey (EncryptedKey ek)
+		{
+			EncryptedKey = ek;
+		}
+
+		#endregion // Constructors
+
+		#region Properties
+
+		public EncryptedKey EncryptedKey {
+			get { return encryptedKey; }
+			set { encryptedKey = value; }
+		}
+
+		#endregion // Properties
+
+		#region Methods
+
+		public override XmlElement GetXml ()
+		{
+			return GetXml (new XmlDocument ());
+		}
+
+		[MonoTODO]
+		internal XmlElement GetXml (XmlDocument document)
+		{
+			if (encryptedKey != null)
+				return encryptedKey.GetXml (document);
+			return null;
+		}
+
+		[MonoTODO]
+		public override void LoadXml (XmlElement value)
+		{
+			EncryptedKey = new EncryptedKey ();
+			EncryptedKey.LoadXml (value);
+		}
+
+		#endregion // Methods
+	}
+}
+
+#endif

+ 41 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/KeyReference.cs

@@ -0,0 +1,41 @@
+//
+// KeyReference.cs - KeyReference implementation for XML Encryption
+// http://www.w3.org/2001/04/xmlenc#sec-ReferenceList
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public sealed class KeyReference : EncryptedReference {
+
+		#region Constructors
+	
+		public KeyReference ()
+			: base ()
+		{
+			ReferenceType = XmlEncryption.ElementNames.KeyReference;
+		}
+	
+		public KeyReference (string uri)
+			: base (uri)
+		{
+			ReferenceType = XmlEncryption.ElementNames.KeyReference;
+		}
+	
+		public KeyReference (string uri, TransformChain tc)
+			: base (uri, tc)
+		{
+			ReferenceType = XmlEncryption.ElementNames.KeyReference;
+		}
+	
+		#endregion // Constructors
+	}
+}
+
+#endif

+ 127 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/ReferenceList.cs

@@ -0,0 +1,127 @@
+//
+// ReferenceList.cs - ReferenceList implementation for XML Encryption
+// http://www.w3.org/2001/04/xmlenc#sec-ReferenceList
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Collections;
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public sealed class ReferenceList : IList, ICollection, IEnumerable {
+
+		#region Fields
+
+		ArrayList list;
+
+		#endregion // Fields
+
+		#region Constructors
+
+		public ReferenceList ()
+		{
+			list = new ArrayList ();
+		}
+	
+		#endregion // Constructors
+
+		#region Properties
+
+		public int Count {
+			get { return list.Count; }
+		}
+
+		object IList.this [int index] {
+			get { return this [index]; }
+			set { this [index] = (EncryptedReference) value; }
+		}
+
+		public bool IsFixedSize {
+			get { return list.IsFixedSize; }
+		}
+
+		public bool IsReadOnly {
+			get { return list.IsReadOnly; }
+		}
+
+		public bool IsSynchronized {
+			get { return list.IsSynchronized; }
+		}
+
+		public EncryptedReference this [int oid] {
+			get { return (EncryptedReference) list [oid]; }
+			set { this [oid] = value; }
+		}
+
+		public object SyncRoot {
+			get { return list.SyncRoot; }
+		}
+
+		#endregion // Properties
+
+		#region Methods
+
+		public int Add (object value)
+		{
+			if (!(value is EncryptedReference))
+				throw new ArgumentException ("value");
+			return list.Add (value);
+		}
+
+		public void Clear ()
+		{
+			list.Clear ();
+		}
+
+		public bool Contains (object value)
+		{
+			return list.Contains (value);
+		}
+
+		public void CopyTo (Array array, int index)
+		{
+			list.CopyTo (array, index);
+		}
+
+		public IEnumerator GetEnumerator ()
+		{
+			return list.GetEnumerator ();
+		}
+
+		public int IndexOf (object value)
+		{
+			return list.IndexOf (value);
+		}
+
+		public void Insert (int index, object value)
+		{
+			if (!(value is EncryptedReference))
+				throw new ArgumentException ("value");
+			list.Insert (index, value);
+		}
+
+		public EncryptedReference Item (int index) 
+		{
+			return (EncryptedReference) list [index];
+		}
+
+		public void Remove (object value)
+		{
+			list.Remove (value);
+		}
+
+		public void RemoveAt (int index)
+		{
+			list.RemoveAt (index);
+		}
+
+		#endregion // Methods
+	}
+}
+
+#endif

+ 18 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/X509IssuerSerial.cs

@@ -0,0 +1,18 @@
+//
+// X509IssuerSerial.cs - X509IssuerSerial implementation for XML Encryption
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+namespace System.Security.Cryptography.Xml {
+	public struct X509IssuerSerial {
+		public string IssuerName;
+		public string SerialNumber;
+	}
+}
+
+#endif

+ 106 - 0
mcs/class/System.Security/System.Security.Cryptography.Xml/XmlDecryptionTransform.cs

@@ -0,0 +1,106 @@
+//
+// XmlDecryptionTransform.cs - XmlDecryptionTransform implementation for XML Encryption
+//
+// Author:
+//      Tim Coleman ([email protected])
+//
+// Copyright (C) Tim Coleman, 2004
+
+#if NET_1_2
+
+using System.Xml;
+
+namespace System.Security.Cryptography.Xml {
+	public class XmlDecryptionTransform : Transform {
+
+		#region Fields
+
+		EncryptedXml encryptedXml;
+		Type[] inputTypes;
+		Type[] outputTypes;
+
+		#endregion // Fields
+
+		#region Constructors
+	
+		public XmlDecryptionTransform ()
+			: base ()
+		{
+		}
+	
+		#endregion // Constructors
+
+		#region Properties
+
+		public EncryptedXml EncryptedXml {
+			get { return encryptedXml; }
+			set { encryptedXml = value; }
+		}
+
+		public override Type[] InputTypes {
+			get { 
+				if (inputTypes == null) {
+					lock (this) {
+						inputTypes = new Type [3] {typeof (System.IO.Stream), typeof (System.Xml.XmlNodeList), typeof (System.Xml.XmlDocument)}; 
+					}
+				}
+				return inputTypes;
+			}
+		}
+
+		public override Type[] OutputTypes {
+			get { 
+				if (outputTypes == null) {
+					lock (this) {
+						outputTypes = new Type [2] {typeof (System.Xml.XmlDocument), typeof (System.Xml.XmlNodeList)};
+					}
+				}
+				return outputTypes;
+			}
+		}
+
+		#endregion // Properties
+
+		#region Methods
+
+		[MonoTODO]
+		protected override XmlNodeList GetInnerXml ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override object GetOutput ()
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override object GetOutput (Type type)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		protected virtual bool IsTargetElement (XmlElement inputElement, string idValue)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override void LoadInnerXml (XmlNodeList nodeList)
+		{
+			throw new NotImplementedException ();
+		}
+
+		[MonoTODO]
+		public override void LoadInput (object obj)
+		{
+			throw new NotImplementedException ();
+		}
+
+		#endregion // Methods
+	}
+}
+
+#endif

+ 6 - 1
mcs/class/System.Security/System.Security.Cryptography.Xml/XmlEncryption.cs

@@ -20,14 +20,19 @@ namespace System.Security.Cryptography.Xml {
 
 		public class ElementNames {
 
+			public const string CarriedKeyName = "CarriedKeyName";
 			public const string CipherData = "CipherData";
 			public const string CipherReference = "CipherReference";
 			public const string CipherValue = "CipherValue";
+			public const string DataReference = "DataReference";
 			public const string EncryptedData = "EncryptedData";
+			public const string EncryptedKey = "EncryptedKey";
 			public const string EncryptionMethod = "EncryptionMethod";
 			public const string EncryptionProperties = "EncryptionProperties";
 			public const string EncryptionProperty = "EncryptionProperty";
+			public const string KeyReference = "KeyReference";
 			public const string KeySize = "KeySize";
+			public const string ReferenceList = "ReferenceList";
 			public const string Transforms = "Transforms";
 
 			public ElementNames () {}
@@ -39,6 +44,7 @@ namespace System.Security.Cryptography.Xml {
 			public const string Encoding = "Encoding";
 			public const string Id = "Id";
 			public const string MimeType = "MimeType";
+			public const string Recipient = "Recipient";
 			public const string Target = "Target";
 			public const string Type = "Type";
 			public const string URI = "URI";
@@ -46,7 +52,6 @@ namespace System.Security.Cryptography.Xml {
 			public AttributeNames () {}
 		}
 
-		public const string NamespaceURI = "http://www.w3.org/2001/04/xmlenc#";
 		public const string Prefix = "xenc";
 
 		public XmlEncryption () {}