diff options
Diffstat (limited to 'crypto/src/asn1/DerT61String.cs')
-rw-r--r-- | crypto/src/asn1/DerT61String.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crypto/src/asn1/DerT61String.cs b/crypto/src/asn1/DerT61String.cs index cc02be41d..8d58747e5 100644 --- a/crypto/src/asn1/DerT61String.cs +++ b/crypto/src/asn1/DerT61String.cs @@ -68,6 +68,23 @@ namespace Org.BouncyCastle.Asn1 return (DerT61String)Meta.Instance.GetContextInstance(taggedObject, declaredExplicit); } + public static DerT61String GetOptional(Asn1Encodable element) + { + if (element == null) + throw new ArgumentNullException(nameof(element)); + + if (element is DerT61String existing) + return existing; + + if (element is IAsn1Convertible asn1Convertible && !(element is Asn1Object) && + asn1Convertible.ToAsn1Object() is DerT61String converted) + { + return converted; + } + + return null; + } + private readonly byte[] m_contents; public DerT61String(string str) |