aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/standalone
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cz/crcs/ectester/standalone/ECTesterStandalone.java86
-rw-r--r--src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java21
2 files changed, 107 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
index cae4bb9..d2cbce1 100644
--- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
+++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
@@ -1,8 +1,90 @@
package cz.crcs.ectester.standalone;
+import cz.crcs.ectester.common.Util;
+import cz.crcs.ectester.applet.EC_Consts;
+import cz.crcs.ectester.common.ec.EC_Curve;
+import cz.crcs.ectester.data.EC_Store;
+import org.apache.commons.cli.*;
+
+import java.io.IOException;
+
+/**
+ * Standalone part of ECTester, a tool for testing Elliptic curve implementations in software libraries.
+ *
+ * @author Jan Jancar johny@neuromancer.sk
+ * @version v0.1.0
+ */
public class ECTesterStandalone {
+ private EC_Store dataStore;
+ private Config cfg;
+
+ private Options opts = new Options();
+ private static final String VERSION = "v0.1.0";
+ private static final String DESCRIPTION = "ECTesterStandalone " + VERSION + ", an Elliptic Curve Cryptography support tester/utility.";
+ private static final String LICENSE = "MIT Licensed\nCopyright (c) 2016-2017 Petr Svenda <petr@svenda.com>";
+ private static final String CLI_HEADER = "\n" + DESCRIPTION + "\n\n";
+ private static final String CLI_FOOTER = "\n" + LICENSE;
+
private void run(String[] args) {
+ try {
+ CommandLine cli = parseArgs(args);
+
+ if (cli.hasOption("help")) {
+ help();
+ return;
+ } else if (cli.hasOption("version")) {
+ version();
+ return;
+ }
+
+ cfg = new Config();
+ dataStore = new EC_Store();
+
+ if (cli.hasOption("generate")) {
+ generate();
+ }
+
+ } catch (ParseException | IOException ex) {
+ System.err.println(ex.getMessage());
+ }
+ }
+
+ private CommandLine parseArgs(String[] args) throws ParseException {
+ OptionGroup actions = new OptionGroup();
+ actions.setRequired(true);
+ actions.addOption(Option.builder("V").longOpt("version").desc("Print version info.").build());
+ actions.addOption(Option.builder("h").longOpt("help").desc("Print help.").build());
+ actions.addOption(Option.builder("g").longOpt("generate").desc("Generate [amount] of EC keys.").hasArg().argName("amount").optionalArg(true).build());
+ opts.addOptionGroup(actions);
+
+ CommandLineParser parser = new DefaultParser();
+ return parser.parse(opts, args);
+ }
+
+ /**
+ * Prints help.
+ */
+ private void help() {
+ HelpFormatter help = new HelpFormatter();
+ help.setOptionComparator(null);
+ help.printHelp("ECTesterStandalone.jar", CLI_HEADER, opts, CLI_FOOTER, true);
+ }
+
+ /**
+ * Prints version info.
+ */
+ private void version() {
+ System.out.println(DESCRIPTION);
+ System.out.println(LICENSE);
+ }
+
+ /**
+ *
+ */
+ private void generate() {
+ EC_Curve curve = dataStore.getObject(EC_Curve.class, "secg/secp192r1");
+ byte[] fp = curve.getParam(EC_Consts.PARAMETER_FP)[0];
}
@@ -10,4 +92,8 @@ public class ECTesterStandalone {
ECTesterStandalone app = new ECTesterStandalone();
app.run(args);
}
+
+ public static class Config {
+
+ }
}
diff --git a/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
new file mode 100644
index 0000000..78da737
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
@@ -0,0 +1,21 @@
+package cz.crcs.ectester.standalone.libs;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import java.security.Security;
+
+public class BouncyCastleLib {
+
+ public BouncyCastleLib() {
+
+ }
+
+ public boolean setUp() {
+ try {
+ Security.addProvider(new BouncyCastleProvider());
+ } catch (NullPointerException | SecurityException ignored) {
+ return false;
+ }
+ return true;
+ }
+
+}