diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-05 18:33:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-05 18:33:27 +0700 |
commit | 215f7bad529b793fc0369fec0dad541d1f93ca7e (patch) | |
tree | b56e5bf37b9124b1a1ff2e6bd8c21e246d508638 /crypto/src/asn1/x509/X509Extensions.cs | |
parent | ASN.1: GetOptional method for all universal types (diff) | |
download | BouncyCastle.NET-ed25519-215f7bad529b793fc0369fec0dad541d1f93ca7e.tar.xz |
Refactoring in Asn1.Cmp
Diffstat (limited to '')
-rw-r--r-- | crypto/src/asn1/x509/X509Extensions.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/src/asn1/x509/X509Extensions.cs b/crypto/src/asn1/x509/X509Extensions.cs index 2893f8b79..193ac8188 100644 --- a/crypto/src/asn1/x509/X509Extensions.cs +++ b/crypto/src/asn1/x509/X509Extensions.cs @@ -220,6 +220,21 @@ namespace Org.BouncyCastle.Asn1.X509 throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), nameof(obj)); } + public static X509Extensions GetOptional(Asn1Encodable element) + { + if (element == null) + throw new ArgumentNullException(nameof(element)); + + if (element is X509Extensions existing) + return existing; + + Asn1Sequence asn1Sequence = Asn1Sequence.GetOptional(element); + if (asn1Sequence != null) + return new X509Extensions(asn1Sequence); + + return null; + } + /** * Constructor from Asn1Sequence. * |