summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Steel <john@steelcomputers.com>2020-10-20 20:56:08 -0400
committerJohn Steel <john@steelcomputers.com>2020-10-20 20:58:01 -0400
commitb536fe17d2464bb91edfead7e51ff69f9866761e (patch)
treef98186313d66ee197cd7ca31a2656b89bfb8ee68
parentUpdating test structure to match existing. (diff)
downloadBouncyCastle.NET-ed25519-b536fe17d2464bb91edfead7e51ff69f9866761e.tar.xz
Supporing .NET 1.1
- removing generics
- removing named params
- replacing 'var' with types
-rw-r--r--crypto/test/src/crypto/test/NistEccTest.cs34
1 files changed, 20 insertions, 14 deletions
diff --git a/crypto/test/src/crypto/test/NistEccTest.cs b/crypto/test/src/crypto/test/NistEccTest.cs
index 8f7d73425..2b0edb63d 100644
--- a/crypto/test/src/crypto/test/NistEccTest.cs
+++ b/crypto/test/src/crypto/test/NistEccTest.cs
@@ -1,8 +1,11 @@
-using System.Collections.Generic;
+using System;
+using System.Collections;
 using System.IO;
 using System.Text.RegularExpressions;
 using NUnit.Framework;
+using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Math.EC;
 using Org.BouncyCastle.Utilities.Test;
 
 namespace Org.BouncyCastle.Crypto.Tests
@@ -14,19 +17,20 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public override void PerformTest()
         {
-            foreach (var testVector in CollectTestVectors())
+            foreach (object[] testVector in CollectTestVectors())
             {
                 TestMultiply(
-                    curve: testVector[0] as string,
-                    k: testVector[1] as BigInteger,
-                    expectedX:testVector[2] as BigInteger,
-                    expectedY: testVector[3] as BigInteger
+                    testVector[0] as string,
+                    testVector[1] as BigInteger,
+                    testVector[2] as BigInteger,
+                    testVector[3] as BigInteger
                     );
             }
         }
 
-        public IEnumerable<object[]> CollectTestVectors()
+        public IEnumerable CollectTestVectors()
         {
+            ArrayList testVectors = new ArrayList();
             string curve = null;
             BigInteger k = null;
             BigInteger x = null;
@@ -37,12 +41,12 @@ namespace Org.BouncyCastle.Crypto.Tests
                 string line;
                 while (null != (line = r.ReadLine()))
                 {
-                    var capture = new Regex(@"^ ?(\w+):? =? ?(\w+)", RegexOptions.Compiled);
-                    var data = capture.Match(line);
+                    Regex capture = new Regex(@"^ ?(\w+):? =? ?(\w+)", RegexOptions.Compiled);
+                    Match data = capture.Match(line);
 
                     if (!data.Success) continue;
-                    var nistKey = data.Groups[1].Value;
-                    var nistValue = data.Groups[2].Value;
+                    string nistKey = data.Groups[1].Value;
+                    string nistValue = data.Groups[2].Value;
                     switch (nistKey)
                     {
                         case "Curve":
@@ -62,22 +66,24 @@ namespace Org.BouncyCastle.Crypto.Tests
 
                     if (null != curve && null != k && null != x && null != y)
                     {
-                        yield return new object[] {curve, k, x, y};
+                        testVectors.Add(new object[] {curve, k, x, y});
                         k = null;
                         x = null;
                         y = null;
                     }
                 }
             }
+
+            return testVectors;
         }
 
         public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigInteger expectedY)
         {
             // Arrange
-            var x9EcParameters = Asn1.Nist.NistNamedCurves.GetByName(curve);
+            X9ECParameters x9EcParameters = Asn1.Nist.NistNamedCurves.GetByName(curve);
 
             // Act
-            var ecPoint = x9EcParameters.G.Multiply(k).Normalize();
+            ECPoint ecPoint = x9EcParameters.G.Multiply(k).Normalize();
 
             // Assert
             IsEquals("Unexpected X Coordinate", expectedX, ecPoint.AffineXCoord.ToBigInteger());