diff options
Diffstat (limited to 'crypto/src/asn1/x509/SubjectPublicKeyInfo.cs')
-rw-r--r-- | crypto/src/asn1/x509/SubjectPublicKeyInfo.cs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crypto/src/asn1/x509/SubjectPublicKeyInfo.cs b/crypto/src/asn1/x509/SubjectPublicKeyInfo.cs index fa1fda4ab..c6f4838db 100644 --- a/crypto/src/asn1/x509/SubjectPublicKeyInfo.cs +++ b/crypto/src/asn1/x509/SubjectPublicKeyInfo.cs @@ -20,11 +20,27 @@ namespace Org.BouncyCastle.Asn1.X509 return new SubjectPublicKeyInfo(Asn1Sequence.GetInstance(obj)); } - public static SubjectPublicKeyInfo GetInstance(Asn1TaggedObject obj, bool explicitly) + public static SubjectPublicKeyInfo GetInstance(Asn1TaggedObject obj, bool explicitly) => + new SubjectPublicKeyInfo(Asn1Sequence.GetInstance(obj, explicitly)); + + public static SubjectPublicKeyInfo GetOptional(Asn1Encodable element) { - return new SubjectPublicKeyInfo(Asn1Sequence.GetInstance(obj, explicitly)); + if (element == null) + throw new ArgumentNullException(nameof(element)); + + if (element is SubjectPublicKeyInfo subjectPublicKeyInfo) + return subjectPublicKeyInfo; + + Asn1Sequence asn1Sequence = Asn1Sequence.GetOptional(element); + if (asn1Sequence != null) + return new SubjectPublicKeyInfo(asn1Sequence); + + return null; } + public static SubjectPublicKeyInfo GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) => + new SubjectPublicKeyInfo(Asn1Sequence.GetTagged(taggedObject, declaredExplicit)); + private readonly AlgorithmIdentifier m_algorithm; private readonly DerBitString m_publicKey; |