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
Cleanup ident handling in standalone.
  • Loading branch information
J08nY committed Aug 2, 2024
commit e1caa815454855bbf2d4bd6582e19d54477383bd
Original file line number Diff line number Diff line change
@@ -43,29 +43,9 @@ protected void runTests() throws Exception {
String kaAlgo = cli.getOptionValue("test.ka-type");
List<String> kaTypes = kaAlgo != null ? Arrays.asList(kaAlgo.split(",")) : new ArrayList<>();

KeyPairGeneratorIdent kpgIdent;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}

Map<String, EC_Key.Public> pubkeys = EC_Store.getInstance().getObjects(EC_Key.Public.class, "cofactor");
Original file line number Diff line number Diff line change
@@ -51,29 +51,9 @@ 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;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}
KeyPairGenerator kpg = kpgIdent.getInstance(cfg.selected.getProvider());

Original file line number Diff line number Diff line change
@@ -33,32 +33,10 @@ protected void runTests() throws Exception {
String sigAlgo = cli.getOptionValue("test.sig-type");
String keyAlgo = cli.getOptionValue("test.key-type", "AES");


KeyPairGeneratorIdent kpgIdent;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}

KeyPairGenerator kpg = kpgIdent.getInstance(cfg.selected.getProvider());

KeyGeneratorTestable kgtOne;
Original file line number Diff line number Diff line change
@@ -42,29 +42,9 @@ protected void runTests() throws Exception {
String kaAlgo = cli.getOptionValue("test.ka-type");
List<String> kaTypes = kaAlgo != null ? Arrays.asList(kaAlgo.split(",")) : new ArrayList<>();

KeyPairGeneratorIdent kpgIdent;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}

Map<String, EC_Key.Public> pubkeys = EC_Store.getInstance().getObjects(EC_Key.Public.class, "degenerate");
Original file line number Diff line number Diff line change
@@ -51,53 +51,13 @@ protected void runTests() throws Exception {
String kaAlgo = cli.getOptionValue("test.ka-type");
String kpgAlgo = cli.getOptionValue("test.kpg-type");

if (kaAlgo == null) {
// try ECDH, if not, fail with: need to specify ka algo.
Optional<KeyAgreementIdent> kaIdentOpt = cfg.selected.getKAs().stream()
.filter((ident) -> ident.contains("ECDH"))
.findFirst();
if (kaIdentOpt.isPresent()) {
kaIdent = kaIdentOpt.get();
} else {
System.err.println("The default KeyAgreement algorithm type of \"ECDH\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong ka algo/not found.
Optional<KeyAgreementIdent> kaIdentOpt = cfg.selected.getKAs().stream()
.filter((ident) -> ident.contains(kaAlgo))
.findFirst();
if (kaIdentOpt.isPresent()) {
kaIdent = kaIdentOpt.get();
} else {
System.err.println("The KeyAgreement algorithm type of \"" + kaAlgo + "\" was not found.");
return;
}
kaIdent = getKeyAgreementIdent(kaAlgo);
if (kaIdent == null) {
return;
}

KeyPairGeneratorIdent kpgIdent;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}
KeyPairGenerator kpg = kpgIdent.getInstance(cfg.selected.getProvider());

Original file line number Diff line number Diff line change
@@ -41,29 +41,9 @@ protected void runTests() throws Exception {
String kaAlgo = cli.getOptionValue("test.ka-type");
List<String> kaTypes = kaAlgo != null ? Arrays.asList(kaAlgo.split(",")) : new ArrayList<>();

KeyPairGeneratorIdent kpgIdent;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}

Map<String, EC_Key.Public> pubkeys = EC_Store.getInstance().getObjects(EC_Key.Public.class, "invalid");
Original file line number Diff line number Diff line change
@@ -51,29 +51,9 @@ 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;
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains(kpgAlgo))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdent = kpgIdentOpt.get();
} else {
System.err.println("The KeyPairGenerator algorithm type of \"" + kpgAlgo + "\" was not found.");
return;
}
KeyPairGeneratorIdent kpgIdent = getKeyPairGeneratorIdent(kpgAlgo);
if (kpgIdent == null) {
return;
}
KeyPairGenerator kpg = kpgIdent.getInstance(cfg.selected.getProvider());

Original file line number Diff line number Diff line change
@@ -48,26 +48,16 @@ protected void runTests() throws Exception {
List<String> sigTypes = sigAlgo != null ? Arrays.asList(sigAlgo.split(",")) : new ArrayList<>();

List<KeyPairGeneratorIdent> kpgIdents = new LinkedList<>();
if (kpgAlgo == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<KeyPairGeneratorIdent> kpgIdentOpt = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.contains("EC"))
.findFirst();
if (kpgIdentOpt.isPresent()) {
kpgIdents.add(kpgIdentOpt.get());
} else {
System.err.println("The default KeyPairGenerator algorithm type of \"EC\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
kpgIdents = cfg.selected.getKPGs().stream()
.filter((ident) -> ident.containsAny(kpgTypes)).collect(Collectors.toList());
if (kpgIdents.isEmpty()) {
System.err.println("No KeyPairGenerator algorithms of specified types were found.");
return;
for (String kpgChoice : kpgTypes) {
KeyPairGeneratorIdent ident = getKeyPairGeneratorIdent(kpgChoice);
if (ident != null && !kpgIdents.contains(ident)) {
kpgIdents.add(ident);
}
}
if (kpgIdents.isEmpty()) {
System.err.println("Need some KeyPairGenerators to be able to generate keys. Select at least one supported one using the -gt/--kpg-type option.");
return;
}

KeyGeneratorTestable kgtOne = null;
KeyGeneratorTestable kgtOther = null;
Original file line number Diff line number Diff line change
@@ -31,29 +31,9 @@ public StandaloneSignatureSuite(TestWriter writer, ECTesterStandalone.Config cfg
protected void runTests() throws Exception {
String sigAlgo = cli.getOptionValue("test.sig-type");

SignatureIdent sigIdent;
if (sigAlgo == null) {
// try ECDSA, if not, fail with: need to specify sig algo.
Optional<SignatureIdent> sigIdentOpt = cfg.selected.getSigs().stream()
.filter((ident) -> ident.contains("ECDSA"))
.findFirst();
if (sigIdentOpt.isPresent()) {
sigIdent = sigIdentOpt.get();
} else {
System.err.println("The default Signature algorithm type of \"ECDSA\" was not found. Need to specify a type.");
return;
}
} else {
// try the specified, if not, fail with: wrong sig algo/not found.
Optional<SignatureIdent> sigIdentOpt = cfg.selected.getSigs().stream()
.filter((ident) -> ident.contains(sigAlgo))
.findFirst();
if (sigIdentOpt.isPresent()) {
sigIdent = sigIdentOpt.get();
} else {
System.err.println("The Signature algorithm type of \"" + sigAlgo + "\" was not found.");
return;
}
SignatureIdent sigIdent = getSignatureIdent(sigAlgo);
if (sigIdent == null) {
return;
}

Map<String, EC_SigResult> results = EC_Store.getInstance().getObjects(EC_SigResult.class, "wrong");
Original file line number Diff line number Diff line change
@@ -4,8 +4,15 @@
import cz.crcs.ectester.common.output.TestWriter;
import cz.crcs.ectester.common.test.TestSuite;
import cz.crcs.ectester.standalone.ECTesterStandalone;
import cz.crcs.ectester.standalone.consts.Ident;
import cz.crcs.ectester.standalone.consts.KeyAgreementIdent;
import cz.crcs.ectester.standalone.consts.KeyPairGeneratorIdent;
import cz.crcs.ectester.standalone.consts.SignatureIdent;
import cz.crcs.ectester.standalone.libs.ProviderECLibrary;

import java.util.Optional;
import java.util.Set;

/**
* @author Jan Jancar johny@neuromancer.sk
*/
@@ -22,4 +29,44 @@ public StandaloneTestSuite(TestWriter writer, ECTesterStandalone.Config cfg, Tre
public ProviderECLibrary getLibrary() {
return cfg.selected;
}

private <T extends Ident> T getIdent(Set<T> options, String choice, String identName, String defaultChoice) {
T ident;
if (choice == null) {
// try EC, if not, fail with: need to specify kpg algo.
Optional<T> identOpt = options.stream()
.filter((i) -> i.contains(defaultChoice))
.findFirst();
if (identOpt.isPresent()) {
ident = identOpt.get();
} else {
System.err.printf("The default %s algorithm type of \"%s\" was not found. Need to specify a type.", identName, defaultChoice);
return null;
}
} else {
// try the specified, if not, fail with: wrong kpg algo/not found.
Optional<T> identOpt = options.stream()
.filter((i) -> i.contains(choice))
.findFirst();
if (identOpt.isPresent()) {
ident = identOpt.get();
} else {
System.err.printf("The %s algorithm type of \"%s\" was not found.", identName, choice);
return null;
}
}
return ident;
}

KeyPairGeneratorIdent getKeyPairGeneratorIdent(String kpgAlgo) {
return getIdent(cfg.selected.getKPGs(), kpgAlgo, "KeyPairGenerator", "EC");
}

KeyAgreementIdent getKeyAgreementIdent(String kaAlgo) {
return getIdent(cfg.selected.getKAs(), kaAlgo, "KeyAgreement", "ECDH");
}

SignatureIdent getSignatureIdent(String sigAlgo) {
return getIdent(cfg.selected.getSigs(), sigAlgo, "Signature", "ECDSA");
}
}
Loading