diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-16 00:03:06 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-16 00:03:06 +0700 |
commit | 0e419469d0b685c5f90485962e94b5e5800811db (patch) | |
tree | e84cbe90ae7254aac9f15177b36136c4628889b0 | |
parent | EC public keys pick up OID from named parameters (diff) | |
download | BouncyCastle.NET-ed25519-0e419469d0b685c5f90485962e94b5e5800811db.tar.xz |
Restore files to before openssh changes
-rw-r--r-- | crypto/src/crypto/ec/CustomNamedCurves.cs | 10 | ||||
-rw-r--r-- | 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<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<DerObjectIdentifier, X9ECParametersHolder> curves = new Dictionary<DerObjectIdentifier, X9ECParametersHolder>(); - private static readonly Dictionary<DerObjectIdentifier, string> objIdToName = + private static readonly Dictionary<DerObjectIdentifier, string> names = new Dictionary<DerObjectIdentifier, string>(); - private static readonly List<string> names = new List<string>(); 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 /// <param name="oid">The <see cref="DerObjectIdentifier">OID</see> for the curve.</param> public static string GetName(DerObjectIdentifier oid) { - return CollectionUtilities.GetValueOrNull(objIdToName, oid); + return CollectionUtilities.GetValueOrNull(names, oid); } /// <summary>Look up the <see cref="DerObjectIdentifier">OID</see> of the curve with the given name.</summary> @@ -917,7 +915,7 @@ namespace Org.BouncyCastle.Crypto.EC /// <summary>Enumerate the available curve names in this registry.</summary> public static IEnumerable<string> 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); |