.NET RSA provider and PEM interchange


PKI support in the .NET framework comes in the form of the RSACryptoServiceProvider class. However PKI is a standard used on all platforms not just .NET so interoperability is important. Strange, then, that the RSACryptoServiceProvider provides no mechanism to save the public and/or private key an RSACryptoServiceProvider instance in a portable format such as PEM.

RSAProviderPEMExchange class in the RSAProviderPEMExchange project aims to plug this gap. The class provides a set of extention methods to save the public or private key of an RSACryptoServiceProvider instance to a file or to create an RSACryptoServiceProvider from a public or private key stored in a .PEM file. The project also includes a demonstration of using the extension methods.

The project uses a subset of the BouncyCastle classes to create and read the PEM file content. The subset used is included in the project though if you are an existing BouncyCastle user you are able to remove the borrowed BC classes and revert to a full distribution.

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Nice article. The code quickly solved my problem by generating PEM files for a given RSA key set. Thank you.