Using BouncyCastle to augment the .NET RSACryptoServiceProvider class
Continuing my detour into cryptography …
While the RSACryptoServiceProvider class allows SHA512 signing, it does not allow SHA512 encryption / decryption.
The BouncyCastle (BC) library does. The issue is how to convert a RSACryptoServiceProvider key to a BC one. The main issue is that the RSACryptoServiceProvider libraries favour byte arrays whereas the BC ones don’t.
Took me a while to figure out how to do the conversion.
The key is to use RSAParameters as the bridge between the two.
The code:
Gist.
Note that the signing can be handled completely within the .NET library whereas the encryption switches over to the BC library.
Enjoy!