/*
* Neuroxiq 2022
* Arctium Project / Code example
*
*
*/
using Arctium.Cryptography.Utils;
using Arctium.Shared.Helpers.Buffers;
using Arctium.Standards.FileFormat.PEM;
using Arctium.Standards.X509.X509Cert;
namespace ConsoleAppTest
{
internal class MainProgram
{
static void Main()
{
X509CertificateDeserializer x509deserialize = new X509CertificateDeserializer();
PemFile pem = PemFile.FromString(X509Certificate_resa_2048_sha256_1);
X509Certificate cert = x509deserialize.FromPem(pem);
if (cert.SubjectPublicKeyInfo.AlgorithmIdentifier.Algorithm == Arctium.Standards.X509.X509Cert.Algorithms.PublicKeyAlgorithmIdentifierType.RSAEncryption)
{
var rsa = cert.SubjectPublicKeyInfo.PublicKey.Choice_RSAEncryption();
Console.WriteLine("RSA");
Console.WriteLine("Modulus: ");
MemDump.HexDump(rsa.Modulus);
Console.WriteLine("Exponent: ");
MemDump.HexDump(rsa.PublicExponent);
}
else if (cert.SubjectPublicKeyInfo.AlgorithmIdentifier.Algorithm == Arctium.Standards.X509.X509Cert.Algorithms.PublicKeyAlgorithmIdentifierType.ECPublicKey)
{
}
else
{
throw new NotSupportedException();
}
}
static readonly string X509Certificate_resa_2048_sha256_1 =
@"
-----BEGIN CERTIFICATE-----
MIID4jCCAsqgAwIBAgIUYYet3/tggZHo5LuPTsOWeDt8M3owDQYJKoZIhvcNAQEL
BQAwXTElMCMGA1UEAwwcd3d3LmFyY2l0dW0tdGVzdGNlcnQtZWNjLmNvbTELMAkG
A1UEBhMCUEwxFjAUBgNVBAgMDUxlc3NlciBQb2xhbmQxDzANBgNVBAcMBktyYWtv
dzAeFw0yMjEwMjIxMDAxNDNaFw0yNTEwMjExMDAxNDNaMF0xJTAjBgNVBAMMHHd3
dy5hcmNpdHVtLXRlc3RjZXJ0LWVjYy5jb20xCzAJBgNVBAYTAlBMMRYwFAYDVQQI
DA1MZXNzZXIgUG9sYW5kMQ8wDQYDVQQHDAZLcmFrb3cwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIB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