Nyamikan.Asn1PKCS 0.1.1

PKCS #1/PKCS #8 RSA key ASN.1 encoder/decoder for C#.

Install-Package Nyamikan.Asn1PKCS -Version 0.1.1
dotnet add package Nyamikan.Asn1PKCS --version 0.1.1
<PackageReference Include="Nyamikan.Asn1PKCS" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nyamikan.Asn1PKCS --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Asn1PKCS

PKCS #1/PKCS #8 RSA key ASN.1 encoder/decoder for C#.

Requirements

  • .NET Standard 1.3

Usage

string derBase64EncodedString = "MEgCQQDOncyWnMXJmnkc5bqmRv5+x/KKes5uBHkoi1rywCLg4YJ1d+BvXSJbQ+bQdEWcporNeYo8hYLIQHZUz1SLiZKZAgMBAAE=";

RSAParameters rsaParameters = PKCS1DERDecoder.DecodePublicKey(derBase64EncodedString);
// rsaParameters.Modulus: byte[] { 0xCE, 0x9D, 0xCC, 0x96, 0x9C, 0xC5, 0xC9, 0x9A, 0x79, 0x1C, 0xE5, 0xBA, 0xA6, 0x46, 0xFE, 0x7E, 0xC7, 0xF2, 0x8A, 0x7A, 0xCE, 0x6E, 0x04, 0x79, 0x28, 0x8B, 0x5A, 0xF2, 0xC0, 0x22, 0xE0, 0xE1, 0x82, 0x75, 0x77, 0xE0, 0x6F, 0x5D, 0x22, 0x5B, 0x43, 0xE6, 0xD0, 0x74, 0x45, 0x9C, 0xA6, 0x8A, 0xCD, 0x79, 0x8A, 0x3C, 0x85, 0x82, 0xC8, 0x40, 0x76, 0x54, 0xCF, 0x54, 0x8B, 0x89, 0x92, 0x99 }
// rsaParameters.Exponent: byte[] { 0x01, 0x00, 0x01 }
RSAParameters rsaParameters = new RSAParameters();
rsaParameters.Modulus = new byte[] { 0xBE, 0x7D, 0xF2, 0xE9, 0x01, 0xCA, 0x41, 0x62, 0x6F, 0x1B, 0x88, 0x8A, 0xB9, 0x65, 0x95, 0x16, 0x25, 0x69, 0xDF, 0xC9, 0xB2, 0x48, 0x3D, 0x96, 0x65, 0x75, 0x13, 0x4D, 0x70, 0x52, 0x19, 0xF0, 0x52, 0xEC, 0xF4, 0x6E, 0xDA, 0x02, 0x76, 0x2C, 0x08, 0xB5, 0xB3, 0x8F, 0x5D, 0x76, 0x99, 0x1D };
rsaParameters.Exponent = new byte[] { 0x11 };

string derBase64EncodedString = PKCS8DEREncoder.EncodePublicKeyToBase64(rsaParameters);
// derBase64EncodedString: "MEowDQYJKoZIhvcNAQEBBQADOQAwNgIxAL598ukBykFibxuIirlllRYlad/Jskg9lmV1E01wUhnwUuz0btoCdiwItbOPXXaZHQIBEQ=="

Other examples: https://github.com/typewriter/Asn1PKCS/tree/master/Asn1PKCSTest

License

MIT

Asn1PKCS

PKCS #1/PKCS #8 RSA key ASN.1 encoder/decoder for C#.

Requirements

  • .NET Standard 1.3

Usage

string derBase64EncodedString = "MEgCQQDOncyWnMXJmnkc5bqmRv5+x/KKes5uBHkoi1rywCLg4YJ1d+BvXSJbQ+bQdEWcporNeYo8hYLIQHZUz1SLiZKZAgMBAAE=";

RSAParameters rsaParameters = PKCS1DERDecoder.DecodePublicKey(derBase64EncodedString);
// rsaParameters.Modulus: byte[] { 0xCE, 0x9D, 0xCC, 0x96, 0x9C, 0xC5, 0xC9, 0x9A, 0x79, 0x1C, 0xE5, 0xBA, 0xA6, 0x46, 0xFE, 0x7E, 0xC7, 0xF2, 0x8A, 0x7A, 0xCE, 0x6E, 0x04, 0x79, 0x28, 0x8B, 0x5A, 0xF2, 0xC0, 0x22, 0xE0, 0xE1, 0x82, 0x75, 0x77, 0xE0, 0x6F, 0x5D, 0x22, 0x5B, 0x43, 0xE6, 0xD0, 0x74, 0x45, 0x9C, 0xA6, 0x8A, 0xCD, 0x79, 0x8A, 0x3C, 0x85, 0x82, 0xC8, 0x40, 0x76, 0x54, 0xCF, 0x54, 0x8B, 0x89, 0x92, 0x99 }
// rsaParameters.Exponent: byte[] { 0x01, 0x00, 0x01 }
RSAParameters rsaParameters = new RSAParameters();
rsaParameters.Modulus = new byte[] { 0xBE, 0x7D, 0xF2, 0xE9, 0x01, 0xCA, 0x41, 0x62, 0x6F, 0x1B, 0x88, 0x8A, 0xB9, 0x65, 0x95, 0x16, 0x25, 0x69, 0xDF, 0xC9, 0xB2, 0x48, 0x3D, 0x96, 0x65, 0x75, 0x13, 0x4D, 0x70, 0x52, 0x19, 0xF0, 0x52, 0xEC, 0xF4, 0x6E, 0xDA, 0x02, 0x76, 0x2C, 0x08, 0xB5, 0xB3, 0x8F, 0x5D, 0x76, 0x99, 0x1D };
rsaParameters.Exponent = new byte[] { 0x11 };

string derBase64EncodedString = PKCS8DEREncoder.EncodePublicKeyToBase64(rsaParameters);
// derBase64EncodedString: "MEowDQYJKoZIhvcNAQEBBQADOQAwNgIxAL598ukBykFibxuIirlllRYlad/Jskg9lmV1E01wUhnwUuz0btoCdiwItbOPXXaZHQIBEQ=="

Other examples: https://github.com/typewriter/Asn1PKCS/tree/master/Asn1PKCSTest

License

MIT

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.1 567 2/7/2019