From 2279aef8b7c00ba2bb71fdedae77ae4a47b00fc6 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sun, 26 Nov 2017 19:19:40 +0100 Subject: Make sure the SPI by the intended provider is always used. - JCA implements failover in its Delegates(classes between a Service and its SPI), which catches RuntimeExceptions and changes to another SPI by possibly another provider, we do not want this to happen. There is no public API for disabling this, however calling .getProvider() on a Service fixates the provider to the returned one. --- .../ectester/standalone/ECTesterStandalone.java | 77 ++++++++++++++-------- 1 file changed, 50 insertions(+), 27 deletions(-) (limited to 'src/cz/crcs/ectester/standalone/ECTesterStandalone.java') diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java index a2c52fc..741d81e 100644 --- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java +++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java @@ -64,11 +64,6 @@ public class ECTesterStandalone { } dataStore = new EC_Store(); - if (cli.hasOption("list-named")) { - CLITools.listNamed(dataStore, cli.getOptionValue("list-named")); - return; - } - for (ECLibrary lib : libs) { lib.initialize(); } @@ -78,15 +73,15 @@ public class ECTesterStandalone { } else if (cli.isNext("list-data")) { CLITools.listNamed(dataStore, cli.getNext().getArg(0)); } else if (cli.isNext("ecdh")) { - + ecdh(); } else if (cli.isNext("ecdsa")) { - + ecdsa(); } else if (cli.isNext("generate")) { generate(); } else if (cli.isNext("test")) { - + test(); } else if (cli.isNext("export")) { - + export(); } } catch (ParseException | NoSuchAlgorithmException | IOException ex) { @@ -145,6 +140,43 @@ public class ECTesterStandalone { return optParser.parse(opts, args); } + /** + * + */ + private void listLibraries() { + for (ECLibrary lib : libs) { + if (lib.isInitialized() && (cfg.selected == null || lib == cfg.selected)) { + System.out.println("\t- " + lib.name()); + Set kpgs = lib.getKPGs(); + if (!kpgs.isEmpty()) { + System.out.println("\t\t- KeyPairGenerators: " + String.join(",", kpgs.stream().map(KeyPairGeneratorIdent::getName).collect(Collectors.toList()))); + } + Set eckas = lib.getECKAs(); + if (!eckas.isEmpty()) { + System.out.println("\t\t- KeyAgreements: " + String.join(",", eckas.stream().map(KeyAgreementIdent::getName).collect(Collectors.toList()))); + } + Set sigs = lib.getECSigs(); + if (!eckas.isEmpty()) { + System.out.println("\t\t- Signatures: " + String.join(",", sigs.stream().map(SignatureIdent::getName).collect(Collectors.toList()))); + } + } + } + } + + /** + * + */ + private void ecdh() { + + } + + /** + * + */ + private void ecdsa() { + + } + /** * */ @@ -192,24 +224,15 @@ public class ECTesterStandalone { /** * */ - private void listLibraries() { - for (ECLibrary lib : libs) { - if (lib.isInitialized() && (cfg.selected == null || lib == cfg.selected)) { - System.out.println("\t- " + lib.name()); - Set kpgs = lib.getKPGs(); - if (!kpgs.isEmpty()) { - System.out.println("\t\t- KeyPairGenerators: " + String.join(",", kpgs.stream().map(KeyPairGeneratorIdent::getName).collect(Collectors.toList()))); - } - Set eckas = lib.getECKAs(); - if (!eckas.isEmpty()) { - System.out.println("\t\t- KeyAgreements: " + String.join(",", eckas.stream().map(KeyAgreementIdent::getName).collect(Collectors.toList()))); - } - Set sigs = lib.getECSigs(); - if (!eckas.isEmpty()) { - System.out.println("\t\t- Signatures: " + String.join(",", sigs.stream().map(SignatureIdent::getName).collect(Collectors.toList()))); - } - } - } + private void test() { + + } + + /** + * + */ + private void export() { + } public static void main(String[] args) { -- cgit v1.2.3-70-g09d2