summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2017-09-17 18:12:41 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2017-09-17 18:12:41 +0700
commitb2f9397b1f0631e7909468bf19816cceb56180f0 (patch)
treee3697b6113f302a114b01c569cf2495f8af6a810
parentImprove exception messages (diff)
downloadBouncyCastle.NET-ed25519-b2f9397b1f0631e7909468bf19816cceb56180f0.tar.xz
Sketch out test changes for ECGOST3410-2012
-rw-r--r--crypto/test/src/test/NamedCurveTest.cs41
1 files changed, 29 insertions, 12 deletions
diff --git a/crypto/test/src/test/NamedCurveTest.cs b/crypto/test/src/test/NamedCurveTest.cs
index 460da233e..f7c831f17 100644
--- a/crypto/test/src/test/NamedCurveTest.cs
+++ b/crypto/test/src/test/NamedCurveTest.cs
@@ -240,18 +240,39 @@ namespace Org.BouncyCastle.Tests
 //			}
         }
 
-        public void doTestECGost(
-            string name)
+        public void doTestECGost(string name)
         {
-//			ECGenParameterSpec ecSpec = new ECGenParameterSpec(name);
-            ECDomainParameters ecSpec = GetCurveParameters(name);
+            ISigner sgr;
+            string keyAlgorithm;
+
+            if (name.IndexOf("Tc26-Gost-3410") == 0)
+            {
+                // TODO Implement ECGOST3410-2012 in SignerUtilies/GeneratorUtilities etc.
+                // Current test cases don't work for GOST34.10 2012
+                return;
+
+                keyAlgorithm = "ECGOST3410-2012";
+                if (name.IndexOf("256") > 0)
+                {
+                    sgr = SignerUtilities.GetSigner("ECGOST3410-2012-256");
+                }
+                else
+                {
+                    sgr = SignerUtilities.GetSigner("ECGOST3410-2012-512");
+                }
+            }
+            else
+            {
+                keyAlgorithm = "ECGOST3410";
 
-            IAsymmetricCipherKeyPairGenerator g = GeneratorUtilities.GetKeyPairGenerator("ECGOST3410");
+                sgr = SignerUtilities.GetSigner("ECGOST3410");
+            }
 
-//			g.initialize(ecSpec, new SecureRandom());
+            ECDomainParameters ecSpec = GetCurveParameters(name);
+
+            IAsymmetricCipherKeyPairGenerator g = GeneratorUtilities.GetKeyPairGenerator(keyAlgorithm);
             g.Init(new ECKeyGenerationParameters(ecSpec, new SecureRandom())); 
 
-            ISigner sgr = SignerUtilities.GetSigner("ECGOST3410");
             AsymmetricCipherKeyPair pair = g.GenerateKeyPair();
             AsymmetricKeyParameter sKey = pair.Private;
             AsymmetricKeyParameter vKey = pair.Public;
@@ -280,7 +301,7 @@ namespace Org.BouncyCastle.Tests
 ////			byte[]              pubEnc = vKey.getEncoded();
 //			byte[] pubEnc = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(vKey).GetDerEncoded();
 //
-////			KeyFactory          keyFac = KeyFactory.getInstance("ECGOST3410");
+////			KeyFactory          keyFac = KeyFactory.getInstance(keyAlgorithm);
 ////			X509EncodedKeySpec  pubX509 = new X509EncodedKeySpec(pubEnc);
 ////			ECPublicKey         pubKey = (ECPublicKey)keyFac.generatePublic(pubX509);
 //			ECPublicKeyParameters pubKey = (ECPublicKeyParameters) PublicKeyFactory.CreateKey(pubEnc);
@@ -369,10 +390,6 @@ namespace Org.BouncyCastle.Tests
 
             foreach (string name in ECGost3410NamedCurves.Names)
             {
-                // Current test cases don't work for GOST34.10 2012
-                if (name.IndexOf("3410-12") >= 0)
-                    continue;
-
                 doTestECGost(name);
             }
         }