EncryptedXml.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //
  2. // EncryptedXml.cs - EncryptedXml implementation for XML Encryption
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2004
  8. #if NET_1_2
  9. using System.Collections;
  10. using System.Security.Policy;
  11. using System.Text;
  12. using System.Xml;
  13. namespace System.Security.Cryptography.Xml {
  14. public class EncryptedXml {
  15. #region Fields
  16. public const string XmlEncAES128KeyWrapUrl = XmlEncNamespaceUrl + "kw-aes128";
  17. public const string XmlEncAES128Url = XmlEncNamespaceUrl + "aes128-cbc";
  18. public const string XmlEncAES192KeyWrapUrl = XmlEncNamespaceUrl + "kw-aes192";
  19. public const string XmlEncAES192Url = XmlEncNamespaceUrl + "aes192-cbc";
  20. public const string XmlEncAES256KeyWrapUrl = XmlEncNamespaceUrl + "kw-aes256";
  21. public const string XmlEncAES256Url = XmlEncNamespaceUrl + "aes256-cbc";
  22. public const string XmlEncDESUrl = XmlEncNamespaceUrl + "des-cbc";
  23. public const string XmlEncElementContentUrl = XmlEncNamespaceUrl + "ElementContent";
  24. public const string XmlEncElementUrl = XmlEncNamespaceUrl + "element";
  25. public const string XmlEncEncryptedKeyUrl = XmlEncNamespaceUrl + "EncryptedKey";
  26. public const string XmlEncNamespaceUrl = "http://www.w3.org/2001/04/xmlenc#";
  27. public const string XmlEncRSA1_5Url = XmlEncNamespaceUrl + "rsa-1_5";
  28. public const string XmlEncRSAOAEPUrl = XmlEncNamespaceUrl + "rsa-oaep-mgf1p";
  29. public const string XmlEncSHA256Url = XmlEncNamespaceUrl + "sha256";
  30. public const string XmlEncSHA512Url = XmlEncNamespaceUrl + "sha512";
  31. public const string XmlEncTripleDESKeyWrapUrl = XmlEncNamespaceUrl + "kw-tripledes";
  32. public const string XmlEncTripleDESUrl = XmlEncNamespaceUrl + "tripledes-cbc";
  33. Evidence documentEvidence;
  34. Encoding encoding = Encoding.UTF8;
  35. Hashtable keyNameMapping = new Hashtable ();
  36. CipherMode mode = CipherMode.CBC;
  37. PaddingMode padding = PaddingMode.ISO10126;
  38. string recipient;
  39. XmlResolver resolver;
  40. #endregion // Fields
  41. #region Constructors
  42. [MonoTODO]
  43. public EncryptedXml ()
  44. {
  45. }
  46. [MonoTODO]
  47. public EncryptedXml (XmlDocument document)
  48. {
  49. }
  50. [MonoTODO]
  51. public EncryptedXml (XmlDocument document, Evidence evidence)
  52. {
  53. DocumentEvidence = evidence;
  54. }
  55. #endregion // Constructors
  56. #region Properties
  57. public Evidence DocumentEvidence {
  58. get { return documentEvidence; }
  59. set { documentEvidence = value; }
  60. }
  61. public Encoding Encoding {
  62. get { return encoding; }
  63. set { encoding = value; }
  64. }
  65. public CipherMode Mode {
  66. get { return mode; }
  67. set { mode = value; }
  68. }
  69. public PaddingMode Padding {
  70. get { return padding; }
  71. set { padding = value; }
  72. }
  73. public string Recipient {
  74. get { return recipient; }
  75. set { recipient = value; }
  76. }
  77. public XmlResolver Resolver {
  78. get { return resolver; }
  79. set { resolver = value; }
  80. }
  81. #endregion // Properties
  82. #region Methods
  83. public void AddKeyNameMapping (string keyName, object keyObject)
  84. {
  85. keyNameMapping [keyName] = keyObject;
  86. }
  87. public void ClearKeyNameMappings ()
  88. {
  89. keyNameMapping.Clear ();
  90. }
  91. [MonoTODO]
  92. public byte[] DecryptData (EncryptedData encryptedData, SymmetricAlgorithm symAlg)
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. [MonoTODO]
  97. public void DecryptDocument ()
  98. {
  99. throw new NotImplementedException ();
  100. }
  101. [MonoTODO]
  102. public virtual byte[] DecryptEncryptedKey (EncryptedKey encryptedKey)
  103. {
  104. throw new NotImplementedException ();
  105. }
  106. [MonoTODO]
  107. public static byte[] DecryptKey (byte[] keyData, SymmetricAlgorithm symAlg)
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. [MonoTODO]
  112. public static byte[] DecryptKey (byte[] keyData, RSA rsa, bool fOAEP)
  113. {
  114. throw new NotImplementedException ();
  115. }
  116. [MonoTODO]
  117. public byte[] EncryptData (XmlElement inputElement, SymmetricAlgorithm symAlg, bool content)
  118. {
  119. throw new NotImplementedException ();
  120. }
  121. [MonoTODO]
  122. public static byte[] EncryptKey (byte[] keyData, SymmetricAlgorithm symAlg)
  123. {
  124. throw new NotImplementedException ();
  125. }
  126. [MonoTODO]
  127. public static byte[] EncryptKey (byte[] keyData, RSA rsa, bool fOAEP)
  128. {
  129. throw new NotImplementedException ();
  130. }
  131. [MonoTODO]
  132. public virtual byte[] GetDecryptionIV (EncryptedData encryptedData, string symAlgUri)
  133. {
  134. throw new NotImplementedException ();
  135. }
  136. [MonoTODO]
  137. public virtual SymmetricAlgorithm GetDecryptionKey (EncryptedData encryptedData, string symAlgUri)
  138. {
  139. throw new NotImplementedException ();
  140. }
  141. public virtual XmlElement GetIdElement (XmlDocument document, string idValue)
  142. {
  143. // this works only if there's a DTD or XSD available to define the ID
  144. XmlElement xel = document.GetElementById (idValue);
  145. if (xel == null) {
  146. // search an "undefined" ID
  147. xel = (XmlElement) document.SelectSingleNode ("//*[@Id='" + idValue + "']");
  148. }
  149. return xel;
  150. }
  151. [MonoTODO]
  152. public static void ReplaceElement (XmlElement inputElement, EncryptedData encryptedData, bool content)
  153. {
  154. throw new NotImplementedException ();
  155. }
  156. #endregion // Methods
  157. }
  158. }
  159. #endif