From 4ea1816cffd5c8663bc9ae1234df0a70ef23fcd6 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 27 Jun 2022 02:19:14 +0700 Subject: Generics migration work --- crypto/src/asn1/anssi/ANSSINamedCurves.cs | 6 +- crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs | 6 +- .../src/asn1/cryptopro/GOST3410NamedParameters.cs | 4 +- crypto/src/asn1/gm/GMNamedCurves.cs | 6 +- crypto/src/asn1/nist/NISTNamedCurves.cs | 4 +- crypto/src/asn1/sec/SECNamedCurves.cs | 6 +- crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs | 6 +- crypto/src/asn1/x509/V2TBSCertListGenerator.cs | 23 ++-- crypto/src/asn1/x509/X509Extensions.cs | 118 +++++++++------------ crypto/src/asn1/x509/X509ExtensionsGenerator.cs | 68 +++++------- crypto/src/asn1/x9/X962NamedCurves.cs | 6 +- 11 files changed, 106 insertions(+), 147 deletions(-) (limited to 'crypto/src/asn1') diff --git a/crypto/src/asn1/anssi/ANSSINamedCurves.cs b/crypto/src/asn1/anssi/ANSSINamedCurves.cs index ed1faa75c..2e164989a 100644 --- a/crypto/src/asn1/anssi/ANSSINamedCurves.cs +++ b/crypto/src/asn1/anssi/ANSSINamedCurves.cs @@ -116,21 +116,21 @@ namespace Org.BouncyCastle.Asn1.Anssi /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs b/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs index ec297f7a1..8e0f55001 100644 --- a/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs +++ b/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs @@ -369,21 +369,21 @@ namespace Org.BouncyCastle.Asn1.CryptoPro /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/cryptopro/GOST3410NamedParameters.cs b/crypto/src/asn1/cryptopro/GOST3410NamedParameters.cs index 2d183a4f9..cd0ab1a80 100644 --- a/crypto/src/asn1/cryptopro/GOST3410NamedParameters.cs +++ b/crypto/src/asn1/cryptopro/GOST3410NamedParameters.cs @@ -88,7 +88,7 @@ namespace Org.BouncyCastle.Asn1.CryptoPro /// The OID for the parameter set. public static Gost3410ParamSetParameters GetByOid(DerObjectIdentifier oid) { - return parameters.TryGetValue(oid, out var parameterSet) ? parameterSet : null; + return CollectionUtilities.GetValueOrNull(parameters, oid); } /// Look up the OID of the parameter set with the given name. @@ -96,7 +96,7 @@ namespace Org.BouncyCastle.Asn1.CryptoPro /// The name of the parameter set. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available parameter set names in this registry. diff --git a/crypto/src/asn1/gm/GMNamedCurves.cs b/crypto/src/asn1/gm/GMNamedCurves.cs index fec0c1401..764b031ed 100644 --- a/crypto/src/asn1/gm/GMNamedCurves.cs +++ b/crypto/src/asn1/gm/GMNamedCurves.cs @@ -147,21 +147,21 @@ namespace Org.BouncyCastle.Asn1.GM /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/nist/NISTNamedCurves.cs b/crypto/src/asn1/nist/NISTNamedCurves.cs index a8bc56549..b9307c879 100644 --- a/crypto/src/asn1/nist/NISTNamedCurves.cs +++ b/crypto/src/asn1/nist/NISTNamedCurves.cs @@ -89,14 +89,14 @@ namespace Org.BouncyCastle.Asn1.Nist /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/sec/SECNamedCurves.cs b/crypto/src/asn1/sec/SECNamedCurves.cs index c0a783ec6..8a97af388 100644 --- a/crypto/src/asn1/sec/SECNamedCurves.cs +++ b/crypto/src/asn1/sec/SECNamedCurves.cs @@ -1248,21 +1248,21 @@ namespace Org.BouncyCastle.Asn1.Sec /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs index b863babce..5edb24045 100644 --- a/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs +++ b/crypto/src/asn1/teletrust/TeleTrusTNamedCurves.cs @@ -527,21 +527,21 @@ namespace Org.BouncyCastle.Asn1.TeleTrust /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. diff --git a/crypto/src/asn1/x509/V2TBSCertListGenerator.cs b/crypto/src/asn1/x509/V2TBSCertListGenerator.cs index 2c929188f..1d58751fd 100644 --- a/crypto/src/asn1/x509/V2TBSCertListGenerator.cs +++ b/crypto/src/asn1/x509/V2TBSCertListGenerator.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; using Org.BouncyCastle.Utilities; @@ -36,7 +36,7 @@ namespace Org.BouncyCastle.Asn1.X509 private X509Name issuer; private Time thisUpdate, nextUpdate; private X509Extensions extensions; - private IList crlEntries; + private List crlEntries; public V2TbsCertListGenerator() { @@ -80,12 +80,11 @@ namespace Org.BouncyCastle.Asn1.X509 this.nextUpdate = nextUpdate; } - public void AddCrlEntry( - Asn1Sequence crlEntry) + public void AddCrlEntry(Asn1Sequence crlEntry) { if (crlEntries == null) { - crlEntries = Platform.CreateArrayList(); + crlEntries = new List(); } crlEntries.Add(crlEntry); @@ -104,8 +103,8 @@ namespace Org.BouncyCastle.Asn1.X509 public void AddCrlEntry(DerInteger userCertificate, Time revocationDate, int reason, DerGeneralizedTime invalidityDate) { - IList extOids = Platform.CreateArrayList(); - IList extValues = Platform.CreateArrayList(); + var extOids = new List(); + var extValues = new List(); if (reason != 0) { @@ -147,8 +146,7 @@ namespace Org.BouncyCastle.Asn1.X509 public void AddCrlEntry(DerInteger userCertificate, Time revocationDate, X509Extensions extensions) { - Asn1EncodableVector v = new Asn1EncodableVector( - userCertificate, revocationDate); + Asn1EncodableVector v = new Asn1EncodableVector(userCertificate, revocationDate); if (extensions != null) { @@ -182,12 +180,7 @@ namespace Org.BouncyCastle.Asn1.X509 // Add CRLEntries if they exist if (crlEntries != null) { - Asn1Sequence[] certs = new Asn1Sequence[crlEntries.Count]; - for (int i = 0; i < crlEntries.Count; ++i) - { - certs[i] = (Asn1Sequence)crlEntries[i]; - } - v.Add(new DerSequence(certs)); + v.Add(new DerSequence(crlEntries.ToArray())); } if (extensions != null) diff --git a/crypto/src/asn1/x509/X509Extensions.cs b/crypto/src/asn1/x509/X509Extensions.cs index b01db1fb5..a399058c2 100644 --- a/crypto/src/asn1/x509/X509Extensions.cs +++ b/crypto/src/asn1/x509/X509Extensions.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; @@ -169,8 +169,9 @@ namespace Org.BouncyCastle.Asn1.X509 */ public static readonly DerObjectIdentifier ExpiredCertsOnCrl = new DerObjectIdentifier("2.5.29.60"); - private readonly IDictionary extensions = Platform.CreateHashtable(); - private readonly IList ordering; + private readonly Dictionary m_extensions = + new Dictionary(); + private readonly List m_ordering; public static X509Extension GetExtension(X509Extensions extensions, DerObjectIdentifier oid) { @@ -182,11 +183,9 @@ namespace Org.BouncyCastle.Asn1.X509 return null == extensions ? null : extensions.GetExtensionParsedValue(oid); } - public static X509Extensions GetInstance( - Asn1TaggedObject obj, - bool explicitly) + public static X509Extensions GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) { - return GetInstance(Asn1Sequence.GetInstance(obj, explicitly)); + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } public static X509Extensions GetInstance( @@ -215,10 +214,9 @@ namespace Org.BouncyCastle.Asn1.X509 * * the extensions are a list of constructed sequences, either with (Oid, OctetString) or (Oid, Boolean, OctetString) */ - private X509Extensions( - Asn1Sequence seq) + private X509Extensions(Asn1Sequence seq) { - this.ordering = Platform.CreateArrayList(); + m_ordering = new List(); foreach (Asn1Encodable ae in seq) { @@ -234,11 +232,11 @@ namespace Org.BouncyCastle.Asn1.X509 Asn1OctetString octets = Asn1OctetString.GetInstance(s[s.Count - 1].ToAsn1Object()); - if (extensions.Contains(oid)) + if (m_extensions.ContainsKey(oid)) throw new ArgumentException("repeated extension found: " + oid); - extensions.Add(oid, new X509Extension(isCritical, octets)); - ordering.Add(oid); + m_extensions.Add(oid, new X509Extension(isCritical, octets)); + m_ordering.Add(oid); } } @@ -247,8 +245,7 @@ namespace Org.BouncyCastle.Asn1.X509 *

* it's is assumed the table contains Oid/string pairs.

*/ - public X509Extensions( - IDictionary extensions) + public X509Extensions(IDictionary extensions) : this(null, extensions) { } @@ -258,22 +255,21 @@ namespace Org.BouncyCastle.Asn1.X509 *

* It's is assumed the table contains Oid/string pairs.

*/ - public X509Extensions( - IList ordering, - IDictionary extensions) + public X509Extensions(IList ordering, + IDictionary extensions) { if (ordering == null) { - this.ordering = Platform.CreateArrayList(extensions.Keys); + m_ordering = new List(extensions.Keys); } else { - this.ordering = Platform.CreateArrayList(ordering); + m_ordering = new List(ordering); } - foreach (DerObjectIdentifier oid in this.ordering) + foreach (DerObjectIdentifier oid in m_ordering) { - this.extensions.Add(oid, (X509Extension)extensions[oid]); + m_extensions.Add(oid, extensions[oid]); } } @@ -283,25 +279,23 @@ namespace Org.BouncyCastle.Asn1.X509 * @param objectIDs an ArrayList of the object identifiers. * @param values an ArrayList of the extension values. */ - public X509Extensions( - IList oids, - IList values) + public X509Extensions(IList oids, IList values) { - this.ordering = Platform.CreateArrayList(oids); + m_ordering = new List(oids); int count = 0; - foreach (DerObjectIdentifier oid in this.ordering) + foreach (DerObjectIdentifier oid in m_ordering) { - this.extensions.Add(oid, (X509Extension)values[count++]); + m_extensions.Add(oid, values[count++]); } } /** * return an Enumeration of the extension field's object ids. */ - public IEnumerable ExtensionOids + public IEnumerable ExtensionOids { - get { return new EnumerableProxy(ordering); } + get { return CollectionUtilities.Proxy(m_ordering); } } /** @@ -310,10 +304,9 @@ namespace Org.BouncyCastle.Asn1.X509 * * @return the extension if it's present, null otherwise. */ - public X509Extension GetExtension( - DerObjectIdentifier oid) + public X509Extension GetExtension(DerObjectIdentifier oid) { - return (X509Extension)extensions[oid]; + return CollectionUtilities.GetValueOrNull(m_extensions, oid); } /** @@ -324,9 +317,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public Asn1Encodable GetExtensionParsedValue(DerObjectIdentifier oid) { - X509Extension ext = GetExtension(oid); - - return ext == null ? null : ext.GetParsedValue(); + return GetExtension(oid)?.GetParsedValue(); } /** @@ -341,44 +332,41 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector vec = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(m_ordering.Count); - foreach (DerObjectIdentifier oid in ordering) + foreach (DerObjectIdentifier oid in m_ordering) { - X509Extension ext = (X509Extension) extensions[oid]; - Asn1EncodableVector v = new Asn1EncodableVector(oid); - - if (ext.IsCritical) + X509Extension ext = m_extensions[oid]; + if (ext.IsCritical) { - v.Add(DerBoolean.True); + v.Add(new DerSequence(oid, DerBoolean.True, ext.Value)); + } + else + { + v.Add(new DerSequence(oid, ext.Value)); } - - v.Add(ext.Value); - - vec.Add(new DerSequence(v)); } - return new DerSequence(vec); + return new DerSequence(v); } - public bool Equivalent( - X509Extensions other) + public bool Equivalent(X509Extensions other) { - if (extensions.Count != other.extensions.Count) + if (m_extensions.Count != other.m_extensions.Count) return false; - foreach (DerObjectIdentifier oid in extensions.Keys) - { - if (!extensions[oid].Equals(other.extensions[oid])) - return false; - } + foreach (var entry in m_extensions) + { + if (!entry.Value.Equals(other.GetExtension(entry.Key))) + return false; + } return true; } public DerObjectIdentifier[] GetExtensionOids() { - return ToOidArray(ordering); + return m_ordering.ToArray(); } public DerObjectIdentifier[] GetNonCriticalExtensionOids() @@ -393,25 +381,17 @@ namespace Org.BouncyCastle.Asn1.X509 private DerObjectIdentifier[] GetExtensionOids(bool isCritical) { - IList oids = Platform.CreateArrayList(); + var oids = new List(); - foreach (DerObjectIdentifier oid in this.ordering) + foreach (DerObjectIdentifier oid in m_ordering) { - X509Extension ext = (X509Extension)extensions[oid]; - if (ext.IsCritical == isCritical) + if (m_extensions[oid].IsCritical == isCritical) { oids.Add(oid); } } - return ToOidArray(oids); - } - - private static DerObjectIdentifier[] ToOidArray(IList oids) - { - DerObjectIdentifier[] oidArray = new DerObjectIdentifier[oids.Count]; - oids.CopyTo(oidArray, 0); - return oidArray; + return oids.ToArray(); } } } diff --git a/crypto/src/asn1/x509/X509ExtensionsGenerator.cs b/crypto/src/asn1/x509/X509ExtensionsGenerator.cs index 3b952fffa..438c507aa 100644 --- a/crypto/src/asn1/x509/X509ExtensionsGenerator.cs +++ b/crypto/src/asn1/x509/X509ExtensionsGenerator.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using Org.BouncyCastle.Utilities; @@ -8,8 +9,9 @@ namespace Org.BouncyCastle.Asn1.X509 /// Generator for X.509 extensions public class X509ExtensionsGenerator { - private IDictionary extensions = Platform.CreateHashtable(); - private IList extOrdering = Platform.CreateArrayList(); + private Dictionary m_extensions = + new Dictionary(); + private List m_ordering = new List(); private static readonly IDictionary dupsAllowed = Platform.CreateHashtable(); @@ -19,16 +21,13 @@ namespace Org.BouncyCastle.Asn1.X509 dupsAllowed.Add(X509Extensions.IssuerAlternativeName, true); dupsAllowed.Add(X509Extensions.SubjectDirectoryAttributes, true); dupsAllowed.Add(X509Extensions.CertificateIssuer, true); - } - - /// Reset the generator public void Reset() { - extensions = Platform.CreateHashtable(); - extOrdering = Platform.CreateArrayList(); + m_extensions = new Dictionary(); + m_ordering = new List(); } /// @@ -38,10 +37,7 @@ namespace Org.BouncyCastle.Asn1.X509 /// OID for the extension. /// True if critical, false otherwise. /// The ASN.1 object to be included in the extension. - public void AddExtension( - DerObjectIdentifier oid, - bool critical, - Asn1Encodable extValue) + public void AddExtension(DerObjectIdentifier oid, bool critical, Asn1Encodable extValue) { byte[] encoded; try @@ -63,38 +59,30 @@ namespace Org.BouncyCastle.Asn1.X509 /// OID for the extension. /// True if critical, false otherwise. /// The byte array to be wrapped. - public void AddExtension( - DerObjectIdentifier oid, - bool critical, - byte[] extValue) + public void AddExtension(DerObjectIdentifier oid, bool critical, byte[] extValue) { - if (extensions.Contains(oid)) + if (m_extensions.TryGetValue(oid, out X509Extension existingExtension)) { - if (dupsAllowed.Contains(oid)) - { - X509Extension existingExtension = (X509Extension)extensions[oid]; - - Asn1Sequence seq1 = Asn1Sequence.GetInstance(DerOctetString.GetInstance(existingExtension.Value).GetOctets()); - Asn1EncodableVector items = Asn1EncodableVector.FromEnumerable(seq1); - Asn1Sequence seq2 = Asn1Sequence.GetInstance(extValue); - - foreach (Asn1Encodable enc in seq2) - { - items.Add(enc); - } + if (!dupsAllowed.Contains(oid)) + throw new ArgumentException("extension " + oid + " already added"); - extensions[oid] = new X509Extension(existingExtension.IsCritical, new DerOctetString(new DerSequence(items).GetEncoded())); + Asn1Sequence seq1 = Asn1Sequence.GetInstance( + Asn1OctetString.GetInstance(existingExtension.Value).GetOctets()); + Asn1EncodableVector items = Asn1EncodableVector.FromEnumerable(seq1); + Asn1Sequence seq2 = Asn1Sequence.GetInstance(extValue); - } - else + foreach (Asn1Encodable enc in seq2) { - throw new ArgumentException("extension " + oid + " already added"); + items.Add(enc); } + + m_extensions[oid] = new X509Extension(existingExtension.IsCritical, + new DerOctetString(new DerSequence(items).GetEncoded())); } else { - extOrdering.Add(oid); - extensions.Add(oid, new X509Extension(critical, new DerOctetString(extValue))); + m_ordering.Add(oid); + m_extensions.Add(oid, new X509Extension(critical, new DerOctetString(extValue))); } } @@ -113,25 +101,23 @@ namespace Org.BouncyCastle.Asn1.X509 /// True if empty, false otherwise public bool IsEmpty { - get { return extOrdering.Count < 1; } + get { return m_ordering.Count < 1; } } /// Generate an X509Extensions object based on the current state of the generator. /// An X509Extensions object public X509Extensions Generate() { - return new X509Extensions(extOrdering, extensions); + return new X509Extensions(m_ordering, m_extensions); } internal void AddExtension(DerObjectIdentifier oid, X509Extension x509Extension) { - if (extensions.Contains(oid)) - { + if (m_extensions.ContainsKey(oid)) throw new ArgumentException("extension " + oid + " already added"); - } - extOrdering.Add(oid); - extensions.Add(oid, x509Extension); + m_ordering.Add(oid); + m_extensions.Add(oid, x509Extension); } } } diff --git a/crypto/src/asn1/x9/X962NamedCurves.cs b/crypto/src/asn1/x9/X962NamedCurves.cs index e0fb625f9..893371fd4 100644 --- a/crypto/src/asn1/x9/X962NamedCurves.cs +++ b/crypto/src/asn1/x9/X962NamedCurves.cs @@ -836,21 +836,21 @@ namespace Org.BouncyCastle.Asn1.X9 /// The OID for the curve. public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return curves.TryGetValue(oid, out var holder) ? holder : null; + return CollectionUtilities.GetValueOrNull(curves, oid); } /// Look up the name of the curve with the given OID. /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return names.TryGetValue(oid, out var name) ? name : null; + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. /// The name of the curve. public static DerObjectIdentifier GetOid(string name) { - return objIds.TryGetValue(name, out var oid) ? oid : null; + return CollectionUtilities.GetValueOrNull(objIds, name); } /// Enumerate the available curve names in this registry. -- cgit 1.4.1