using System; namespace Org.BouncyCastle.Asn1.X509 { /** * The object that contains the public key stored in a certficate. *
* The GetEncoded() method in the public keys in the JCE produces a DER * encoded one of these.
*/ public class SubjectPublicKeyInfo : Asn1Encodable { public static SubjectPublicKeyInfo GetInstance(object obj) { if (obj == null) return null; if (obj is SubjectPublicKeyInfo subjectPublicKeyInfo) return subjectPublicKeyInfo; return new SubjectPublicKeyInfo(Asn1Sequence.GetInstance(obj)); } public static SubjectPublicKeyInfo GetInstance(Asn1TaggedObject obj, bool explicitly) { return new SubjectPublicKeyInfo(Asn1Sequence.GetInstance(obj, explicitly)); } private readonly AlgorithmIdentifier m_algorithm; private readonly DerBitString m_publicKey; public SubjectPublicKeyInfo(AlgorithmIdentifier algID, DerBitString publicKey) { m_algorithm = algID; m_publicKey = publicKey; } public SubjectPublicKeyInfo(AlgorithmIdentifier algID, Asn1Encodable publicKey) { m_algorithm = algID; m_publicKey = new DerBitString(publicKey); } public SubjectPublicKeyInfo(AlgorithmIdentifier algID, byte[] publicKey) { m_algorithm = algID; m_publicKey = new DerBitString(publicKey); } #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public SubjectPublicKeyInfo(AlgorithmIdentifier algID, ReadOnlySpan* SubjectPublicKeyInfo ::= Sequence { * algorithm AlgorithmIdentifier, * publicKey BIT STRING } **/ public override Asn1Object ToAsn1Object() => new DerSequence(m_algorithm, m_publicKey); } }