Using DecryptDocument with Super-Encrypted Data
The EncryptedXml class comes with a nice utility method called DecryptDocument (For more information about using DecryptDocument check out my previous post introducing XML Encryption). This method will decrypt all the EncryptedData elements it finds, assuming that it is able to figure out what key to use to perform the decryption with. However, what happens if you use this method with some super encrypted data?
Super encryption is defined in the XML Encryption standard as encrypting an EncryptedData element (providing that you encrypt the entirety of the element). In other words, it's encrypting already encrypted data.
The DecryptDocument method will decrypt all top-level EncryptedData elements, however if they are super-encrypted, it will not continue to loop over the document to decrypt the resulting EncryptedData. If you want to fully decrypt a document containing super-encrypted data, you'll need to do this looping yourself. (Or if you want to be sure that you've fully decrypted a document, and you can't be sure if it contains super encrypted data or not).
The code to do this is very simple, you just need to keep calling DecryptDocument while EncryptedData elements still exist.
while(doc.GetElementsByTagName("EncryptedData", EncryptedXml.XmlEncNamespaceUrl).Count > 0 )
exml.DecryptDocument();
Comments
- Anonymous
May 16, 2005
The www.53dy.com is free movies web site , all movies is free !
Welcome to our web site !
http://www.53dy.com">http://www.53dy.com
免费电影 www.53dy.com 全部电影完全免费!
欢迎光临免费电影
http://www.53dy.com">http://www.53dy.com
The www.k58.org is free movies web site , all movies is free !
Welcome to our web site !
http://www.k58.org">http://www.k58.org
免费电影 www.k58.org 全部电影完全免费!
欢迎光临免费电影
http://www.k58.org">http://www.k58.org - Anonymous
March 08, 2006
http://www.51k.org