diff options
author | Jozef Gajdos <jozef.gajdos@disig.sk> | 2023-03-17 12:14:18 +0100 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-20 15:35:20 +0700 |
commit | 6274d5ff7d471093f8fa4c934a7674cbdee558fb (patch) | |
tree | 8b6d62620228cd18cb40431b4b0951b9bc2b9faf /crypto | |
parent | Add EdDsa_Legacy (diff) | |
download | BouncyCastle.NET-ed25519-6274d5ff7d471093f8fa4c934a7674cbdee558fb.tar.xz |
Add suport of SubjectPublicKeyInfo in Org.BouncyCastle.OpenSsl.PemWriter
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/openssl/MiscPemGenerator.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crypto/src/openssl/MiscPemGenerator.cs b/crypto/src/openssl/MiscPemGenerator.cs index fe2583063..cafbdedbb 100644 --- a/crypto/src/openssl/MiscPemGenerator.cs +++ b/crypto/src/openssl/MiscPemGenerator.cs @@ -99,6 +99,11 @@ namespace Org.BouncyCastle.OpenSsl encoding = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(akp).GetDerEncoded(); } } + else if (obj is SubjectPublicKeyInfo subjectPublicKeyInfo) + { + type = "PUBLIC KEY"; + encoding = subjectPublicKeyInfo.GetEncoded(); + } else if (obj is X509V2AttributeCertificate attrCert) { type = "ATTRIBUTE CERTIFICATE"; @@ -240,8 +245,8 @@ namespace Org.BouncyCastle.OpenSsl #endif private static byte[] EncodePrivateKey( - AsymmetricKeyParameter akp, - out string keyType) + AsymmetricKeyParameter akp, + out string keyType) { PrivateKeyInfo info = PrivateKeyInfoFactory.CreatePrivateKeyInfo(akp); AlgorithmIdentifier algID = info.PrivateKeyAlgorithm; @@ -253,7 +258,7 @@ namespace Org.BouncyCastle.OpenSsl DsaParameter p = DsaParameter.GetInstance(algID.Parameters); - BigInteger x = ((DsaPrivateKeyParameters) akp).X; + BigInteger x = ((DsaPrivateKeyParameters)akp).X; BigInteger y = p.G.ModPow(x, p.P); // TODO Create an ASN1 object somewhere for this? |