diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-18 16:12:06 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-18 16:12:06 +0700 |
commit | 740c25a020c7539c99e82dd4531492c5b6bbd787 (patch) | |
tree | 998874b3c9d7b80636919b44de639218c9622f29 /crypto/src/asn1/x509/CertificateList.cs | |
parent | DerInteger constants for small values (diff) | |
download | BouncyCastle.NET-ed25519-740c25a020c7539c99e82dd4531492c5b6bbd787.tar.xz |
Refactoring in Asn1.Cms
Diffstat (limited to '')
-rw-r--r-- | crypto/src/asn1/x509/CertificateList.cs | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/crypto/src/asn1/x509/CertificateList.cs b/crypto/src/asn1/x509/CertificateList.cs index 5d73cf411..ecf22e372 100644 --- a/crypto/src/asn1/x509/CertificateList.cs +++ b/crypto/src/asn1/x509/CertificateList.cs @@ -19,24 +19,39 @@ namespace Org.BouncyCastle.Asn1.X509 public class CertificateList : Asn1Encodable { - private readonly TbsCertificateList tbsCertList; - private readonly AlgorithmIdentifier sigAlgID; - private readonly DerBitString sig; + public static CertificateList GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is CertificateList certificateList) + return certificateList; + return new CertificateList(Asn1Sequence.GetInstance(obj)); + } public static CertificateList GetInstance(Asn1TaggedObject obj, bool explicitly) { return GetInstance(Asn1Sequence.GetInstance(obj, explicitly)); } - public static CertificateList GetInstance(object obj) + public static CertificateList GetOptional(Asn1Encodable element) { - if (obj == null) - return null; - if (obj is CertificateList certificateList) + if (element == null) + throw new ArgumentNullException(nameof(element)); + + if (element is CertificateList certificateList) return certificateList; - return new CertificateList(Asn1Sequence.GetInstance(obj)); + + Asn1Sequence asn1Sequence = Asn1Sequence.GetOptional(element); + if (asn1Sequence != null) + return new CertificateList(asn1Sequence); + + return null; } + private readonly TbsCertificateList tbsCertList; + private readonly AlgorithmIdentifier sigAlgID; + private readonly DerBitString sig; + private CertificateList( Asn1Sequence seq) { |