aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ08nY2019-07-10 15:02:42 +0200
committerJ08nY2019-07-10 15:02:42 +0200
commit3925f8b3221bb42db0f84d5a23ad5220e3f6f93b (patch)
treef6ab9cf12f11b9b88d323c99d67714eef9d735df /src
parent2a0947cdfaa0fc5a7cf6c438612c0073e3ff6272 (diff)
downloadECTester-3925f8b3221bb42db0f84d5a23ad5220e3f6f93b.tar.gz
ECTester-3925f8b3221bb42db0f84d5a23ad5220e3f6f93b.tar.zst
ECTester-3925f8b3221bb42db0f84d5a23ad5220e3f6f93b.zip
Diffstat (limited to 'src')
-rw-r--r--src/cz/crcs/ectester/standalone/ECTesterStandalone.java37
-rw-r--r--src/cz/crcs/ectester/standalone/consts/Ident.java2
-rw-r--r--src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java5
-rw-r--r--src/cz/crcs/ectester/standalone/consts/KeyPairGeneratorIdent.java5
-rw-r--r--src/cz/crcs/ectester/standalone/consts/SignatureIdent.java5
5 files changed, 49 insertions, 5 deletions
diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
index 489eb40..cad1737 100644
--- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
+++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
@@ -80,7 +80,8 @@ public class ECTesterStandalone {
new MscngLib(),
new WolfCryptLib(),
new MbedTLSLib(),
- new IppcpLib()};
+ new IppcpLib(),
+ new MatrixsslLib()};
private Config cfg;
private Options opts = new Options();
@@ -109,6 +110,7 @@ public class ECTesterStandalone {
return;
}
+ //TODO: push this further down to only initialize if necessary.
for (ECLibrary lib : libs) {
lib.initialize();
}
@@ -124,6 +126,8 @@ public class ECTesterStandalone {
CLITools.listNamed(EC_Store.getInstance(), cli.getNext().getArg(0));
} else if (cli.isNext("list-suites")) {
listSuites();
+ } else if (cli.isNext("list-types")) {
+ listIdents();
} else if (cli.isNext("ecdh")) {
ecdh();
} else if (cli.isNext("ecdsa")) {
@@ -238,6 +242,10 @@ public class ECTesterStandalone {
ParserOptions listSuites = new ParserOptions(new DefaultParser(), listSuitesOpts, "List supported test suites.");
actions.put("list-suites", listSuites);
+ Options listIdentsOpts = new Options();
+ ParserOptions listIdents = new ParserOptions(new DefaultParser(), listIdentsOpts, "List KeyPairGenerator, KeyAgreement and Signature types.");
+ actions.put("list-types", listIdents);
+
List<Argument> baseArgs = new LinkedList<>();
baseArgs.add(new Argument("lib", "What library to use.", false));
optParser = new TreeParser(actions, false, baseArgs);
@@ -256,6 +264,7 @@ public class ECTesterStandalone {
for (ProviderECLibrary lib : libs) {
if (lib.isInitialized() && (cfg.selected == null || lib == cfg.selected)) {
System.out.println("\t- " + Colors.bold(lib.name()));
+ System.out.println(Colors.bold("\t\t- Version: ") + String.format("%f", lib.getProvider().getVersion()));
System.out.println(Colors.bold("\t\t- Supports native timing: ") + lib.supportsNativeTiming());
Set<KeyPairGeneratorIdent> kpgs = lib.getKPGs();
if (!kpgs.isEmpty()) {
@@ -294,6 +303,24 @@ public class ECTesterStandalone {
/**
*
*/
+ private void listIdents() {
+ System.out.println(Colors.bold("\t- KeyPairGenerator"));
+ for (KeyPairGeneratorIdent kpgIdent : KeyPairGeneratorIdent.list()) {
+ System.out.println("\t\t- " + Colors.underline(kpgIdent.getName()) + " " + kpgIdent.toString());
+ }
+ System.out.println(Colors.bold("\t- KeyAgreement"));
+ for (KeyAgreementIdent kaIdent : KeyAgreementIdent.list()) {
+ System.out.println("\t\t- " + Colors.underline(kaIdent.getName()) + " " + kaIdent.toString());
+ }
+ System.out.println(Colors.bold("\t- Signature"));
+ for (SignatureIdent sigIdent : SignatureIdent.list()) {
+ System.out.println("\t\t- " + Colors.underline(sigIdent.getName()) + " " + sigIdent.toString());
+ }
+ }
+
+ /**
+ *
+ */
private void ecdh() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException {
ProviderECLibrary lib = cfg.selected;
@@ -357,7 +384,8 @@ public class ECTesterStandalone {
out = System.out;
}
- out.println("index;time[nano];pubW;privS;secret");
+ String hashAlgo = kaIdent.getBaseAlgo() != null ? String.format("[%s]", kaIdent.getBaseAlgo()) : "[NONE]";
+ out.println("index;time[nano];pubW;privS;secret" + hashAlgo);
KeyPair one = null;
if (cli.hasOption("ecdh.fixed-private") && !cli.hasOption("ecdh.named-private") && !cli.hasOption("ecdh.private")) {
@@ -503,7 +531,8 @@ public class ECTesterStandalone {
out = System.out;
}
- out.println("index;signTime[nano];verifyTime[nano];data;pubW;privS;signature;nonce;verified");
+ String hashAlgo = sigIdent.getHashAlgo() != null ? String.format("[%s]", sigIdent.getHashAlgo()) : "";
+ out.println("index;signTime[nano];verifyTime[nano];data;pubW;privS;signature" + hashAlgo + ";nonce;verified");
ECPrivateKey privkey = (ECPrivateKey) ECUtil.loadKey(EC_Consts.PARAMETER_S, cli.getOptionValue("ecdsa.named-private"), cli.getOptionValue("ecdsa.private"), spec);
ECPublicKey pubkey = (ECPublicKey) ECUtil.loadKey(EC_Consts.PARAMETER_W, cli.getOptionValue("ecdsa.named-public"), cli.getOptionValue("ecdsa.public"), spec);
@@ -719,7 +748,7 @@ public class ECTesterStandalone {
}
}
- if (!cli.isNext("list-data") && !cli.isNext("list-suites")) {
+ if (!cli.isNext("list-data") && !cli.isNext("list-suites") && !cli.isNext("list-types")) {
String libraryName = cli.getArg(-1);
if (libraryName != null) {
List<ProviderECLibrary> matchedLibs = new LinkedList<>();
diff --git a/src/cz/crcs/ectester/standalone/consts/Ident.java b/src/cz/crcs/ectester/standalone/consts/Ident.java
index 29603c2..1c7a962 100644
--- a/src/cz/crcs/ectester/standalone/consts/Ident.java
+++ b/src/cz/crcs/ectester/standalone/consts/Ident.java
@@ -77,6 +77,6 @@ public abstract class Ident {
@Override
public String toString() {
- return "(" + String.join("|", idents) + ")";
+ return "(" + String.join(" | ", idents) + ")";
}
}
diff --git a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java
index 808f298..9b912cb 100644
--- a/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java
+++ b/src/cz/crcs/ectester/standalone/consts/KeyAgreementIdent.java
@@ -3,6 +3,7 @@ package cz.crcs.ectester.standalone.consts;
import javax.crypto.KeyAgreement;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -73,6 +74,10 @@ public class KeyAgreementIdent extends Ident {
return null;
}
+ public static List<KeyAgreementIdent> list() {
+ return Collections.unmodifiableList(ALL);
+ }
+
private KeyAgreementIdent(String name, String... aliases) {
super(name, aliases);
if (name.contains("with")) {
diff --git a/src/cz/crcs/ectester/standalone/consts/KeyPairGeneratorIdent.java b/src/cz/crcs/ectester/standalone/consts/KeyPairGeneratorIdent.java
index 332b78e..83eef75 100644
--- a/src/cz/crcs/ectester/standalone/consts/KeyPairGeneratorIdent.java
+++ b/src/cz/crcs/ectester/standalone/consts/KeyPairGeneratorIdent.java
@@ -3,6 +3,7 @@ package cz.crcs.ectester.standalone.consts;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -32,6 +33,10 @@ public class KeyPairGeneratorIdent extends Ident {
return null;
}
+ public static List<KeyPairGeneratorIdent> list() {
+ return Collections.unmodifiableList(ALL);
+ }
+
public KeyPairGeneratorIdent(String name, String... aliases) {
super(name, aliases);
}
diff --git a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java
index 7f9adb4..39b8031 100644
--- a/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java
+++ b/src/cz/crcs/ectester/standalone/consts/SignatureIdent.java
@@ -3,6 +3,7 @@ package cz.crcs.ectester.standalone.consts;
import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.security.Signature;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -92,6 +93,10 @@ public class SignatureIdent extends Ident {
return null;
}
+ public static List<SignatureIdent> list() {
+ return Collections.unmodifiableList(ALL);
+ }
+
private SignatureIdent(String name, String... aliases) {
super(name, aliases);
if (name.contains("with")) {