Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

How to use RSACryptoServiceProvider.ImportParameters()

$
0
0

Hi everyone!

 

I have a very non-descript error message of "Bad Data" displayed for a CryptographicException when trying to import just the Modulus and Exponent (the Public Key) when using the RSACryptoServiceProvider class.

 

I am aware that the RSAParameters struct properties needs an object of type of byte[], however from some comments in some very complicated examples I have found it needs to be big-endian (ie, call Array.Reverse(byte[])). I tried this but still got the "Bad Data" error... strange how there's no mention of big-endian style arrays in any MSDN info, or any information on what format the RSACryptoServiceProvider expects to find RSAParameters.Modulus and .Exponent in, other than it being a byte array that is.

 

I have not found any simple examples of setting the RSAParameters.Modulus and RSAParameters.Exponent from something like a large integer, or a string of numerical characters that are representing a large integer? All the examples cheat by using the RSACryptoServiceProvider.ExportParameters() method right before calling the .ImportParameters() method, supposedly showing the usage of the two methods (albeit NOT A REAL WORLD example).

 

If anyone out there can give me an example of what kind of Converts to perform on the string or integer before putting the data in an array it would make my week!

 

Cheers for your time,

Voss.


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>