EncryptedXml OAEP - null reference issue

roaderbrain

New Member
so I have one issue with EncryptedXml decrypting using OAEP. I have part of code which encrypts some xml like this:\[code\] ... byte[] encryptedElement = eXml.EncryptData(elementToEncrypt, sessionKey, true); EncryptedData edElement = new EncryptedData(); edElement.Type = EncryptedXml.XmlEncElementUrl; edElement.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncRSAOAEPUrl); ...\[/code\]when I try to decrypt it like this:\[code\] EncryptedXml exml = new EncryptedXml(document); var provider = (RSA)_certificate.PrivateKey; exml.AddKeyNameMapping("rsaKey", provider); exml.DecryptDocument();\[/code\]EncryptedXml throws exception: \[quote\] Object reference not set to an instance of an object.\[/quote\]And in stack trace is this method: at System.Security.Cryptography.Xml.EncryptedXml.GetDecryptionKey(EncryptedData encryptedData, String symmetricAlgorithmUri)When I'm using EncryptedXml.XmlEncAES256Url everything is fine and it works without problem. But I need use EncryptedXml.XmlEncRSAOAEPUrl.Any idea what's wrong?
 
Back
Top