diff options
author | John Steel <git@jskw.dev> | 2020-10-17 12:08:00 -0400 |
---|---|---|
committer | John Steel <git@jskw.dev> | 2020-10-17 12:25:43 -0400 |
commit | 23e2e6565aa4f368a2851a6683c2c0c6e260ab1f (patch) | |
tree | 5dd021fdb31c46fe6942844150a9d98b528e9dd6 /crypto/test | |
parent | Test Vectors for EC Point Multiply (diff) | |
download | BouncyCastle.NET-ed25519-23e2e6565aa4f368a2851a6683c2c0c6e260ab1f.tar.xz |
Updating test structure to match existing.
Diffstat (limited to 'crypto/test')
-rw-r--r-- | crypto/test/src/crypto/test/NistEccTest.cs | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/crypto/test/src/crypto/test/NistEccTest.cs b/crypto/test/src/crypto/test/NistEccTest.cs index 7e658ff3e..8f7d73425 100644 --- a/crypto/test/src/crypto/test/NistEccTest.cs +++ b/crypto/test/src/crypto/test/NistEccTest.cs @@ -7,8 +7,24 @@ using Org.BouncyCastle.Utilities.Test; namespace Org.BouncyCastle.Crypto.Tests { - public class NistEccTest + [TestFixture] + public class NistEccTest : SimpleTest { + public override string Name { get; } = "NistEcc"; + + public override void PerformTest() + { + foreach (var testVector in CollectTestVectors()) + { + TestMultiply( + curve: testVector[0] as string, + k: testVector[1] as BigInteger, + expectedX:testVector[2] as BigInteger, + expectedY: testVector[3] as BigInteger + ); + } + } + public IEnumerable<object[]> CollectTestVectors() { string curve = null; @@ -55,7 +71,6 @@ namespace Org.BouncyCastle.Crypto.Tests } } - [TestCaseSource(nameof(CollectTestVectors))] public void TestMultiply(string curve, BigInteger k, BigInteger expectedX, BigInteger expectedY) { // Arrange @@ -65,8 +80,21 @@ namespace Org.BouncyCastle.Crypto.Tests var ecPoint = x9EcParameters.G.Multiply(k).Normalize(); // Assert - Assert.AreEqual(expectedX, ecPoint.XCoord.ToBigInteger(), "Unexpected X Coordinate"); - Assert.AreEqual(expectedY, ecPoint.YCoord.ToBigInteger(), "Unexpected Y Coordinate"); + IsEquals("Unexpected X Coordinate", expectedX, ecPoint.AffineXCoord.ToBigInteger()); + IsEquals("Unexpected Y Coordinate", expectedY, ecPoint.AffineYCoord.ToBigInteger()); + } + + public static void Main(string[] args) + { + RunTest(new NistEccTest()); + } + + [Test] + public void TestFunction() + { + string resultText = Perform().ToString(); + + Assert.AreEqual(Name + ": Okay", resultText); } } } \ No newline at end of file |