summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-01-26 20:57:47 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-01-26 20:57:47 +0700
commit2aff60a7982e1a5616172a84b8eb05c219052aef (patch)
treee0a774fed45b9b2b9f180019b26e4a8fac120ce9 /crypto/src
parentFormatting (diff)
downloadBouncyCastle.NET-ed25519-2aff60a7982e1a5616172a84b8eb05c219052aef.tar.xz
Use custom curve if available
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/crypto/generators/ECKeyPairGenerator.cs19
-rw-r--r--crypto/src/openssl/PEMReader.cs19
2 files changed, 10 insertions, 28 deletions
diff --git a/crypto/src/crypto/generators/ECKeyPairGenerator.cs b/crypto/src/crypto/generators/ECKeyPairGenerator.cs
index a936755e2..d1387a55c 100644
--- a/crypto/src/crypto/generators/ECKeyPairGenerator.cs
+++ b/crypto/src/crypto/generators/ECKeyPairGenerator.cs
@@ -6,6 +6,7 @@ using Org.BouncyCastle.Asn1.Sec;
 using Org.BouncyCastle.Asn1.TeleTrust;
 using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.EC;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Math.EC;
@@ -89,7 +90,7 @@ namespace Org.BouncyCastle.Crypto.Generators
         }
 
         /**
-         * Given the domain parameters this routine Generates an EC key
+         * Given the domain parameters this routine generates an EC key
          * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
          */
         public AsymmetricCipherKeyPair GenerateKeyPair()
@@ -121,23 +122,11 @@ namespace Org.BouncyCastle.Crypto.Generators
         {
             // TODO ECGost3410NamedCurves support (returns ECDomainParameters though)
 
-            X9ECParameters ecP = X962NamedCurves.GetByOid(oid);
-
+            X9ECParameters ecP = CustomNamedCurves.GetByOid(oid);
             if (ecP == null)
             {
-                ecP = SecNamedCurves.GetByOid(oid);
-
-                if (ecP == null)
-                {
-                    ecP = NistNamedCurves.GetByOid(oid);
-
-                    if (ecP == null)
-                    {
-                        ecP = TeleTrusTNamedCurves.GetByOid(oid);
-                    }
-                }
+                ecP = ECNamedCurveTable.GetByOid(oid);
             }
-
             return ecP;
         }
 
diff --git a/crypto/src/openssl/PEMReader.cs b/crypto/src/openssl/PEMReader.cs
index b3a1177ce..9d3560838 100644
--- a/crypto/src/openssl/PEMReader.cs
+++ b/crypto/src/openssl/PEMReader.cs
@@ -12,6 +12,7 @@ using Org.BouncyCastle.Asn1.TeleTrust;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Crypto.EC;
 using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Pkcs;
@@ -382,24 +383,16 @@ namespace Org.BouncyCastle.OpenSsl
             string name)
         {
             // TODO ECGost3410NamedCurves support (returns ECDomainParameters though)
-            X9ECParameters ecP = X962NamedCurves.GetByName(name);
 
+            X9ECParameters ecP = CustomNamedCurves.GetByName(name);
             if (ecP == null)
             {
-                ecP = SecNamedCurves.GetByName(name);
-                if (ecP == null)
-                {
-                    ecP = NistNamedCurves.GetByName(name);
-                    if (ecP == null)
-                    {
-                        ecP = TeleTrusTNamedCurves.GetByName(name);
-
-                        if (ecP == null)
-                            throw new Exception("unknown curve name: " + name);
-                    }
-                }
+                ecP = ECNamedCurveTable.GetByName(name);
             }
 
+            if (ecP == null)
+                throw new Exception("unknown curve name: " + name);
+
             //return new ECDomainParameters(ecP.Curve, ecP.G, ecP.N, ecP.H, ecP.GetSeed());
             return ecP;
         }