The problem you have is that the XML provided by your client does not match the format required for deserialization for an object of type RSAParameters
I ran this code to show what the XML generated by the XML serializer looks like
var provider = new RSACryptoServiceProvider(); var parameters = provider.ExportParameters(true); var x = new XmlSerializer(parameters.GetType()); x.Serialize(Console.Out, parameters); Console.WriteLine();
The result that it creates looks something like this:
<RSAParameters> <Exponent>AQAB</Exponent> <Modulus>ruCEpD3XnR...g/waE=</Modulus> <P>90amUU3dDazsqN9+...jJUQ==</P> <Q>tQv5hGehNLLmv4aC...NfUQ==</Q> <DP>azJiiZ6itPoBQph...zBcQ==</DP> <DQ>OmewiOw9bxi/o82...f44Q==</DQ> <InverseQ>wNohk0NNl...YDg==</InverseQ> <D>fNOOWp46FckcvtI+...PpXAE=</D> </RSAParameters>
where ... is the truncated conclusion. What your client has provided looks like a superset (key, text and cipher are not included in the parameter list), but the format is slightly different.
You can either ask them to provide the data in the exact format you want, and then serialize; or you can accept their format, deserialize it in XML, and create the RSAParameters object manually by matching the XML contents with the corresponding fields in the RSAParameters object. You also need to figure out what they want to do with key, text, and encrypted data, as they will be lost in the process.
briantyler
source share