Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test selection #33

Merged
merged 25 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8523e5b
Remove runTest from CardCompositeSuite.
J08nY Aug 1, 2024
6f257dc
Fix infinity test in card compression suite.
J08nY Aug 1, 2024
1a81ced
Add testing of ECTesterReader suites with Jcardsim.
J08nY Aug 1, 2024
474bc97
Upload code-coverage for reader CI run as well.
J08nY Aug 1, 2024
0887928
Improve exception printing.
J08nY Aug 1, 2024
21a43b1
Add timeouts to reader tests.
J08nY Aug 1, 2024
b3fe06d
Add more reader tests.
J08nY Aug 1, 2024
3639e10
No more runTest in reader.
J08nY Aug 1, 2024
522515f
Disable tests that may cycle indefinitely.
J08nY Aug 2, 2024
6c34421
Add codecov config.
J08nY Aug 2, 2024
ea3e1ba
Fix codecov.yml
J08nY Aug 2, 2024
efd218b
Aggregate test coverage over subprojects.
J08nY Aug 2, 2024
70b95b6
Move coverage reports where codecov finds them.
J08nY Aug 2, 2024
386e01e
Make standalone Cofactor suite not use runTest.
J08nY Aug 2, 2024
e1caa81
Cleanup ident handling in standalone.
J08nY Aug 2, 2024
6f0e99c
Standalone cleanup.
J08nY Aug 2, 2024
40c5061
Move conversion to custom curve to params class.
J08nY Aug 2, 2024
93ab84c
Remove runTest from edge-cases suite.
J08nY Aug 2, 2024
12d83b8
Remove runTest from wrong suite.
J08nY Aug 2, 2024
c7ddf94
Remove runTest from misc suite.
J08nY Aug 2, 2024
be0fc8c
Fix Botan ECKCDSA.
J08nY Aug 2, 2024
2990dc3
Remove runTest from performance suite.
J08nY Aug 2, 2024
6009793
Remove runTest from composite suite.
J08nY Aug 2, 2024
6cb0cf8
Unify Invalid, Degenerate and Twist suites on standalone.
J08nY Aug 2, 2024
6ed466c
Remove runTest from the rest of the standalone suites.
J08nY Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove runTest from misc suite.
  • Loading branch information
J08nY committed Aug 2, 2024
commit c7ddf947a8f7939c5a29265ef94617de6df7d8ef
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ public static ECPoint fromX962(byte[] data, EllipticCurve curve) {
}
}

private static byte[] hashCurve(EC_Curve curve) {
public static byte[] hashCurve(EC_Curve curve) {
int bytes = (curve.getBits() + 7) / 8;
byte[] result = new byte[bytes];
SHA1Digest digest = new SHA1Digest();
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import cz.crcs.ectester.common.test.CompoundTest;
import cz.crcs.ectester.common.test.Result;
import cz.crcs.ectester.common.test.Test;
import cz.crcs.ectester.common.util.ByteUtil;
import cz.crcs.ectester.data.EC_Store;
import cz.crcs.ectester.standalone.ECTesterStandalone;
import cz.crcs.ectester.standalone.consts.KeyAgreementIdent;
@@ -22,6 +23,8 @@
import java.security.interfaces.ECPublicKey;
import java.util.*;

import static cz.crcs.ectester.common.util.ECUtil.hashCurve;

/**
* @author David Hofman
*/
@@ -50,7 +53,7 @@ protected void runTests() throws Exception {

kaTypes = kaAlgo != null ? Arrays.asList(kaAlgo.split(",")) : new ArrayList<>();
sigTypes = sigAlgo != null ? Arrays.asList(sigAlgo.split(",")) : new ArrayList<>();

KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
@@ -78,29 +81,18 @@ protected void runTests() throws Exception {
private void testCurve(EC_Curve curve, String catName, KeyPairGenerator kpg, Result.ExpectedValue expected) throws NoSuchAlgorithmException {
//generate KeyPair
KeyGeneratorTestable kgt = new KeyGeneratorTestable(kpg, curve.toSpec());
Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);
runTest(generate);
KeyPair kp = kgt.getKeyPair();
if(kp == null) {
Test generateFail = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generating KeyPair has failed on " + curve.getId() +
". " + " Other tests will be skipped.", generate);
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests over " + curve.getBits() + "b " + catName + " curve: " + curve.getId() + ".", generateFail));
return;
}
Test generateSuccess = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Generate keypair.", generate);
ECPrivateKey ecpriv = (ECPrivateKey) kp.getPrivate();
ECPublicKey ecpub = (ECPublicKey) kp.getPublic();
Test generate = KeyGeneratorTest.expectError(kgt, Result.ExpectedValue.ANY);

//perform KeyAgreement tests
List<Test> kaTests = new LinkedList<>();
for (KeyAgreementIdent kaIdent : cfg.selected.getKAs()) {
if (kaAlgo == null || kaIdent.containsAny(kaTypes)) {
KeyAgreement ka = kaIdent.getInstance(cfg.selected.getProvider());
KeyAgreementTestable testable = new KeyAgreementTestable(ka, ecpriv, ecpub);
KeyAgreementTestable testable = new KeyAgreementTestable(ka, kgt, kgt);
kaTests.add(KeyAgreementTest.expectError(testable, expected));
}
}
if(kaTests.isEmpty()) {
if (kaTests.isEmpty()) {
kaTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified KeyAgreement types is supported by the library."));
}

@@ -109,17 +101,17 @@ private void testCurve(EC_Curve curve, String catName, KeyPairGenerator kpg, Res
for (SignatureIdent sigIdent : cfg.selected.getSigs()) {
if (sigAlgo == null || sigIdent.containsAny(sigTypes)) {
Signature sig = sigIdent.getInstance(cfg.selected.getProvider());
SignatureTestable testable = new SignatureTestable(sig, ecpriv, ecpub, null);
SignatureTestable testable = new SignatureTestable(sig, kgt, hashCurve(curve));
sigTests.add(SignatureTest.expectError(testable, expected));
}
}
if(sigTests.isEmpty()) {
if (sigTests.isEmpty()) {
sigTests.add(CompoundTest.all(Result.ExpectedValue.SUCCESS, "None of the specified Signature types is supported by the library."));
}

Test performKeyAgreements = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform specified KeyAgreements.", kaTests.toArray(new Test[0]));
Test performSignatures = CompoundTest.all(Result.ExpectedValue.SUCCESS, "Perform specified Signatures.", sigTests.toArray(new Test[0]));
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests over " + curve.getBits() + "b " + catName + " curve: " + curve.getId() + ".", generateSuccess, performKeyAgreements, performSignatures));
doTest(CompoundTest.all(Result.ExpectedValue.SUCCESS, "Tests over " + curve.getBits() + "b " + catName + " curve: " + curve.getId() + ".", generate, performKeyAgreements, performSignatures));
}

private void testCurves(Collection<EC_Curve> curves, String catName, KeyPairGenerator kpg, Result.ExpectedValue expected) throws NoSuchAlgorithmException {