Skip to content

Commit b536fe1

Browse files
Supporing .NET 1.1
- removing generics - removing named params - replacing 'var' with types
1 parent 23e2e65 commit b536fe1

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

crypto/test/src/crypto/test/NistEccTest.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections;
23
using System.IO;
34
using System.Text.RegularExpressions;
45
using NUnit.Framework;
6+
using Org.BouncyCastle.Asn1.X9;
57
using Org.BouncyCastle.Math;
8+
using Org.BouncyCastle.Math.EC;
69
using Org.BouncyCastle.Utilities.Test;
710

811
namespace Org.BouncyCastle.Crypto.Tests
@@ -14,19 +17,20 @@ public class NistEccTest : SimpleTest
1417

1518
public override void PerformTest()
1619
{
17-
foreach (var testVector in CollectTestVectors())
20+
foreach (object[] testVector in CollectTestVectors())
1821
{
1922
TestMultiply(
20-
curve: testVector[0] as string,
21-
k: testVector[1] as BigInteger,
22-
expectedX:testVector[2] as BigInteger,
23-
expectedY: testVector[3] as BigInteger
23+
testVector[0] as string,
24+
testVector[1] as BigInteger,
25+
testVector[2] as BigInteger,
26+
testVector[3] as BigInteger
2427
);
2528
}
2629
}
2730

28-
public IEnumerable<object[]> CollectTestVectors()
31+
public IEnumerable CollectTestVectors()
2932
{
33+
ArrayList testVectors = new ArrayList();
3034
string curve = null;
3135
BigInteger k = null;
3236
BigInteger x = null;
@@ -37,12 +41,12 @@ public IEnumerable<object[]> CollectTestVectors()
3741
string line;
3842
while (null != (line = r.ReadLine()))
3943
{
40-
var capture = new Regex(@"^ ?(\w+):? =? ?(\w+)", RegexOptions.Compiled);
41-
var data = capture.Match(line);
44+
Regex capture = new Regex(@"^ ?(\w+):? =? ?(\w+)", RegexOptions.Compiled);
45+
Match data = capture.Match(line);
4246

4347
if (!data.Success) continue;
44-
var nistKey = data.Groups[1].Value;
45-
var nistValue = data.Groups[2].Value;
48+
string nistKey = data.Groups[1].Value;
49+
string nistValue = data.Groups[2].Value;
4650
switch (nistKey)
4751
{
4852
case "Curve":
@@ -62,22 +66,24 @@ public IEnumerable<object[]> CollectTestVectors()
6266

6367
if (null != curve && null != k && null != x && null != y)
6468
{
65-
yield return new object[] {curve, k, x, y};
69+
testVectors.Add(new object[] {curve, k, x, y});
6670
k = null;
6771
x = null;
6872
y = null;
6973
}
7074
}
7175
}
76+
77+
return testVectors;
7278
}
7379

7480
public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigInteger expectedY)
7581
{
7682
// Arrange
77-
var x9EcParameters = Asn1.Nist.NistNamedCurves.GetByName(curve);
83+
X9ECParameters x9EcParameters = Asn1.Nist.NistNamedCurves.GetByName(curve);
7884

7985
// Act
80-
var ecPoint = x9EcParameters.G.Multiply(k).Normalize();
86+
ECPoint ecPoint = x9EcParameters.G.Multiply(k).Normalize();
8187

8288
// Assert
8389
IsEquals("Unexpected X Coordinate", expectedX, ecPoint.AffineXCoord.ToBigInteger());

0 commit comments

Comments
 (0)