From 386e01e2a47557acc9440001d40314374e5d982f Mon Sep 17 00:00:00 2001 From: J08nY Date: Fri, 2 Aug 2024 14:32:31 +0200 Subject: Make standalone Cofactor suite not use runTest. --- .../standalone/test/base/KeyAgreementTestable.java | 37 ++++++++++++++++++++-- .../test/suites/StandaloneCofactorSuite.java | 24 +++++++------- 2 files changed, 46 insertions(+), 15 deletions(-) (limited to 'standalone/src/main/java/cz/crcs/ectester') diff --git a/standalone/src/main/java/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java b/standalone/src/main/java/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java index 7fd1c5a..24c25c5 100644 --- a/standalone/src/main/java/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java +++ b/standalone/src/main/java/cz/crcs/ectester/standalone/test/base/KeyAgreementTestable.java @@ -46,7 +46,7 @@ public class KeyAgreementTestable extends StandaloneTestable allKaTests = new LinkedList<>(); for (KeyAgreementIdent kaIdent : cfg.selected.getKAs()) { @@ -94,7 +87,7 @@ public class StandaloneCofactorSuite extends StandaloneTestSuite { for (EC_Key.Public pub : keys) { ECPublicKey ecpub = ECUtil.toPublicKey(pub); KeyAgreement ka = kaIdent.getInstance(cfg.selected.getProvider()); - KeyAgreementTestable testable = new KeyAgreementTestable(ka, ecpriv, ecpub); + KeyAgreementTestable testable = new KeyAgreementTestable(ka, ecpub, kgt); Test keyAgreement = KeyAgreementTest.expectError(testable, Result.ExpectedValue.FAILURE); specificKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, pub.getId() + " cofactor key test.", keyAgreement)); } @@ -104,8 +97,15 @@ public class StandaloneCofactorSuite extends StandaloneTestSuite { if (allKaTests.isEmpty()) { allKaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified key agreement types is supported by the library.")); } - Test tests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0])); - doTest(CompoundTest.greedyAllTry(Result.ExpectedValue.SUCCESS, "Cofactor test of " + curve.getId() + ".", generateSuccess, tests)); + Test kaTests = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Do tests.", allKaTests.toArray(new Test[0])); + Function callback = (tests) -> CompoundTest.EXPECT_ALL.apply(Result.ExpectedValue.SUCCESS, tests); + Consumer runCallback = (tests) -> { + tests[0].run(); + if (tests[0].getResult().getValue().equals(Result.Value.SUCCESS)) { + tests[1].run(); + } + }; + doTest(CompoundTest.function(callback, runCallback, "Cofactor test of " + curve.getId() + ".", generate, kaTests)); } } } -- cgit v1.2.3-70-g09d2