summary refs log tree commit diff
path: root/crypto/src/asn1/x9/ECNamedCurveTable.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2017-09-16 19:09:28 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2017-09-16 19:09:28 +0700
commit3b9aaf9221bc63a32c96be074bb505a86b389121 (patch)
treee1fee760570449825e1a40f7883f3da9d642cf82 /crypto/src/asn1/x9/ECNamedCurveTable.cs
parentPort of ConcatenationKdfGenerator from Java (diff)
downloadBouncyCastle.NET-ed25519-3b9aaf9221bc63a32c96be074bb505a86b389121.tar.xz
Add GOST34.10 2012 parameter sets
Diffstat (limited to 'crypto/src/asn1/x9/ECNamedCurveTable.cs')
-rw-r--r--crypto/src/asn1/x9/ECNamedCurveTable.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crypto/src/asn1/x9/ECNamedCurveTable.cs b/crypto/src/asn1/x9/ECNamedCurveTable.cs
index 317ef17b4..f91bded18 100644
--- a/crypto/src/asn1/x9/ECNamedCurveTable.cs
+++ b/crypto/src/asn1/x9/ECNamedCurveTable.cs
@@ -2,10 +2,12 @@
 using System.Collections;
 
 using Org.BouncyCastle.Asn1.Anssi;
+using Org.BouncyCastle.Asn1.CryptoPro;
 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;
 
@@ -44,6 +46,10 @@ namespace Org.BouncyCastle.Asn1.X9
             }
             if (ecP == null)
             {
+                ecP = FromDomainParameters(ECGost3410NamedCurves.GetByName(name));
+            }
+            if (ecP == null)
+            {
                 ecP = GMNamedCurves.GetByName(name);
             }
             return ecP;
@@ -70,6 +76,10 @@ namespace Org.BouncyCastle.Asn1.X9
             }
             if (name == null)
             {
+                name = ECGost3410NamedCurves.GetName(oid);
+            }
+            if (name == null)
+            {
                 name = GMNamedCurves.GetName(oid);
             }
             return name;
@@ -102,6 +112,10 @@ namespace Org.BouncyCastle.Asn1.X9
             }
             if (oid == null)
             {
+                oid = ECGost3410NamedCurves.GetOid(name);
+            }
+            if (oid == null)
+            {
                 oid = GMNamedCurves.GetOid(name);
             }
             return oid;
@@ -134,6 +148,10 @@ namespace Org.BouncyCastle.Asn1.X9
             }
             if (ecP == null)
             {
+                ecP = FromDomainParameters(ECGost3410NamedCurves.GetByOid(oid));
+            }
+            if (ecP == null)
+            {
                 ecP = GMNamedCurves.GetByOid(oid);
             }
             return ecP;
@@ -154,9 +172,15 @@ namespace Org.BouncyCastle.Asn1.X9
                 CollectionUtilities.AddRange(v, NistNamedCurves.Names);
                 CollectionUtilities.AddRange(v, TeleTrusTNamedCurves.Names);
                 CollectionUtilities.AddRange(v, AnssiNamedCurves.Names);
+                CollectionUtilities.AddRange(v, ECGost3410NamedCurves.Names);
                 CollectionUtilities.AddRange(v, GMNamedCurves.Names);
                 return v;
             }
         }
+
+        private static X9ECParameters FromDomainParameters(ECDomainParameters dp)
+        {
+            return dp == null ? null : new X9ECParameters(dp.Curve, dp.G, dp.N, dp.H, dp.GetSeed());
+        }
     }
 }