diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-02-03 15:19:53 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-02-03 15:19:53 +0700 |
commit | b3a8c7160ce31e8b4ef03dc862f1dc7cfa0dd480 (patch) | |
tree | 241a1811db06dc3ceed1e61281f5e6ecb6388058 /crypto/src/asn1/nist | |
parent | Remove Obsolete methods (diff) | |
download | BouncyCastle.NET-ed25519-b3a8c7160ce31e8b4ef03dc862f1dc7cfa0dd480.tar.xz |
Improve curve registry laziness
Diffstat (limited to 'crypto/src/asn1/nist')
-rw-r--r-- | crypto/src/asn1/nist/NISTNamedCurves.cs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crypto/src/asn1/nist/NISTNamedCurves.cs b/crypto/src/asn1/nist/NISTNamedCurves.cs index f6c1598c6..ee256cc2b 100644 --- a/crypto/src/asn1/nist/NISTNamedCurves.cs +++ b/crypto/src/asn1/nist/NISTNamedCurves.cs @@ -50,11 +50,16 @@ namespace Org.BouncyCastle.Asn1.Nist DefineCurveAlias("P-521", SecObjectIdentifiers.SecP521r1); } - public static X9ECParameters GetByName( - string name) + public static X9ECParameters GetByName(string name) + { + DerObjectIdentifier oid = GetOid(name); + return oid == null ? null : SecNamedCurves.GetByOid(oid); + } + + public static X9ECParametersHolder GetByNameLazy(string name) { DerObjectIdentifier oid = GetOid(name); - return oid == null ? null : GetByOid(oid); + return oid == null ? null : SecNamedCurves.GetByOidLazy(oid); } /** @@ -63,10 +68,14 @@ namespace Org.BouncyCastle.Asn1.Nist * * @param oid an object identifier representing a named curve, if present. */ - public static X9ECParameters GetByOid( - DerObjectIdentifier oid) + public static X9ECParameters GetByOid(DerObjectIdentifier oid) + { + return names.Contains(oid) ? SecNamedCurves.GetByOid(oid) : null; + } + + public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid) { - return SecNamedCurves.GetByOid(oid); + return names.Contains(oid) ? SecNamedCurves.GetByOidLazy(oid) : null; } /** |