From 0e419469d0b685c5f90485962e94b5e5800811db Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sun, 16 Apr 2023 00:03:06 +0700 Subject: Restore files to before openssh changes --- crypto/src/crypto/ec/CustomNamedCurves.cs | 10 ++++------ crypto/src/pkcs/PrivateKeyInfoFactory.cs | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crypto/src/crypto/ec/CustomNamedCurves.cs b/crypto/src/crypto/ec/CustomNamedCurves.cs index 7bf274be4..d256dba73 100644 --- a/crypto/src/crypto/ec/CustomNamedCurves.cs +++ b/crypto/src/crypto/ec/CustomNamedCurves.cs @@ -782,16 +782,14 @@ namespace Org.BouncyCastle.Crypto.EC new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary curves = new Dictionary(); - private static readonly Dictionary objIdToName = + private static readonly Dictionary names = new Dictionary(); - private static readonly List names = new List(); private static void DefineCurve(string name, DerObjectIdentifier oid, X9ECParametersHolder holder) { objIds.Add(name, oid); - objIdToName.Add(oid, name); + names.Add(oid, name); curves.Add(oid, holder); - names.Add(name); } private static void DefineCurveAlias(string name, DerObjectIdentifier oid) @@ -904,7 +902,7 @@ namespace Org.BouncyCastle.Crypto.EC /// The OID for the curve. public static string GetName(DerObjectIdentifier oid) { - return CollectionUtilities.GetValueOrNull(objIdToName, oid); + return CollectionUtilities.GetValueOrNull(names, oid); } /// Look up the OID of the curve with the given name. @@ -917,7 +915,7 @@ namespace Org.BouncyCastle.Crypto.EC /// Enumerate the available curve names in this registry. public static IEnumerable Names { - get { return CollectionUtilities.Proxy(names); } + get { return CollectionUtilities.Proxy(objIds.Keys); } } } } diff --git a/crypto/src/pkcs/PrivateKeyInfoFactory.cs b/crypto/src/pkcs/PrivateKeyInfoFactory.cs index 1baf2dd9f..d56831f35 100644 --- a/crypto/src/pkcs/PrivateKeyInfoFactory.cs +++ b/crypto/src/pkcs/PrivateKeyInfoFactory.cs @@ -164,16 +164,16 @@ namespace Org.BouncyCastle.Pkcs else { X962Parameters x962; - if (dp is ECNamedDomainParameters _dp) - { - x962 = new X962Parameters(_dp.Name); - } - else + if (priv.PublicKeyParamSet == null) { X9ECParameters ecP = new X9ECParameters(dp.Curve, new X9ECPoint(dp.G, false), dp.N, dp.H, dp.GetSeed()); x962 = new X962Parameters(ecP); } + else + { + x962 = new X962Parameters(priv.PublicKeyParamSet); + } ec = new ECPrivateKeyStructure(orderBitLength, priv.D, publicKey, x962); -- cgit 1.4.1