Pempublic: X.509 SubjectPublicKeyInfo Decoder


Pempublic.cs is a .NET Framework 1.1/2.0 console utility which manually parses an asn.1 encoded public key file in the X.509 SubjectPublicKeyInfo format. This is the standard encoding format in Java 2 and OpenSSL. Pempublic prompts for a local file which can be a binary encoded SubjectPublicKeyInfo or a PEM b64 encoded version, with or without header/footer lines. Pempublic sequentially parses the asn.1 structure, checking for asn.1 validity. This utility supports any RSA keysize currently supported by Win32 (modulus size up to 16,384 bits or 2048 bytes). If the file is parsed correctly, the modulus and exponent data is displayed in hex and this data is used to instantiate a .NET RSACryptoServiceProvider instance using oRSA.ImportParameters(oRSAParameters). Then the XML exported public key format is also displayed using oRSA.ToXmlString(false). If any errors occur during parsing, the application exits.

C# Source

Sample output for 4096 bit RSA key

See also Using ASN.1 encoded public keys in .NET



Michel I. Gallant
neutron@istar.ca