diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-17 22:07:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2020-07-17 22:07:12 +0700 |
commit | 2db28a5b63aadd34fb3ef350d69eb4db4e4580b4 (patch) | |
tree | 119f0a21af644d1e5e2e2ba9ab4658f2fd69dcaf /crypto/src/asn1 | |
parent | Spelling (diff) | |
download | BouncyCastle.NET-ed25519-2db28a5b63aadd34fb3ef350d69eb4db4e4580b4.tar.xz |
Straighten out ECGOST3410NamedCurves
- deprecate/replace methods returning ECDomainParameters
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r-- | crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs | 27 | ||||
-rw-r--r-- | crypto/src/asn1/x9/ECNamedCurveTable.cs | 10 |
2 files changed, 19 insertions, 18 deletions
diff --git a/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs b/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs index 92c9312c7..99fb34bf7 100644 --- a/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs +++ b/crypto/src/asn1/cryptopro/ECGOST3410NamedCurves.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using Org.BouncyCastle.Asn1.Rosstandart; +using Org.BouncyCastle.Asn1.X9; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Math; using Org.BouncyCastle.Math.EC; @@ -228,12 +229,18 @@ namespace Org.BouncyCastle.Asn1.CryptoPro * * @param oid an object identifier representing a named parameters, if present. */ - public static ECDomainParameters GetByOid( - DerObjectIdentifier oid) + [Obsolete("Use 'GetByOidX9' instead")] + public static ECDomainParameters GetByOid(DerObjectIdentifier oid) { return (ECDomainParameters)parameters[oid]; } + public static X9ECParameters GetByOidX9(DerObjectIdentifier oid) + { + ECDomainParameters ec = (ECDomainParameters)parameters[oid]; + return ec == null ? null : new X9ECParameters(ec.Curve, new X9ECPoint(ec.G, false), ec.N, ec.H, ec.GetSeed()); + } + /** * returns an enumeration containing the name strings for curves * contained in this structure. @@ -243,17 +250,17 @@ namespace Org.BouncyCastle.Asn1.CryptoPro get { return new EnumerableProxy(names.Values); } } - public static ECDomainParameters GetByName( - string name) + [Obsolete("Use 'GetByNameX9' instead")] + public static ECDomainParameters GetByName(string name) { DerObjectIdentifier oid = (DerObjectIdentifier)objIds[name]; + return oid == null ? null : (ECDomainParameters)parameters[oid]; + } - if (oid != null) - { - return (ECDomainParameters)parameters[oid]; - } - - return null; + public static X9ECParameters GetByNameX9(string name) + { + DerObjectIdentifier oid = (DerObjectIdentifier)objIds[name]; + return oid == null ? null : GetByOidX9(oid); } /** diff --git a/crypto/src/asn1/x9/ECNamedCurveTable.cs b/crypto/src/asn1/x9/ECNamedCurveTable.cs index f91bded18..fcd2810e7 100644 --- a/crypto/src/asn1/x9/ECNamedCurveTable.cs +++ b/crypto/src/asn1/x9/ECNamedCurveTable.cs @@ -7,7 +7,6 @@ using Org.BouncyCastle.Asn1.GM; using Org.BouncyCastle.Asn1.Nist; using Org.BouncyCastle.Asn1.Sec; using Org.BouncyCastle.Asn1.TeleTrust; -using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; @@ -46,7 +45,7 @@ namespace Org.BouncyCastle.Asn1.X9 } if (ecP == null) { - ecP = FromDomainParameters(ECGost3410NamedCurves.GetByName(name)); + ecP = ECGost3410NamedCurves.GetByNameX9(name); } if (ecP == null) { @@ -148,7 +147,7 @@ namespace Org.BouncyCastle.Asn1.X9 } if (ecP == null) { - ecP = FromDomainParameters(ECGost3410NamedCurves.GetByOid(oid)); + ecP = ECGost3410NamedCurves.GetByOidX9(oid); } if (ecP == null) { @@ -177,10 +176,5 @@ namespace Org.BouncyCastle.Asn1.X9 return v; } } - - private static X9ECParameters FromDomainParameters(ECDomainParameters dp) - { - return dp == null ? null : new X9ECParameters(dp.Curve, dp.G, dp.N, dp.H, dp.GetSeed()); - } } } |