From 9e615b101398bd4c8e2678bf86337e2756a8ee7a Mon Sep 17 00:00:00 2001
From: J08nY
Date: Sun, 12 Nov 2017 23:39:35 +0100
Subject: Implement collecting of supported KeyAgreement and Signature objects.
---
src/cz/crcs/ectester/standalone/libs/SunECLib.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 src/cz/crcs/ectester/standalone/libs/SunECLib.java
(limited to 'src/cz/crcs/ectester/standalone/libs/SunECLib.java')
diff --git a/src/cz/crcs/ectester/standalone/libs/SunECLib.java b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
new file mode 100644
index 0000000..408908e
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
@@ -0,0 +1,14 @@
+package cz.crcs.ectester.standalone.libs;
+
+import sun.security.ec.SunEC;
+
+/**
+ * @author Jan Jancar johny@neuromancer.sk
+ */
+public class SunECLib extends JavaECLibrary {
+
+ public SunECLib() {
+ super(new SunEC());
+ }
+
+}
--
cgit v1.2.3-70-g09d2
From 9bce1e13ec136c06650868acf3438e789e366d5f Mon Sep 17 00:00:00 2001
From: J08nY
Date: Mon, 27 Nov 2017 23:19:48 +0100
Subject: Add a basic NativeECLibrary interface.
---
build-standalone.xml | 5 +
nbproject/reader/project.properties | 2 +-
nbproject/standalone/project.properties | 2 +-
.../ectester/standalone/ECTesterStandalone.java | 10 +-
.../ectester/standalone/libs/BouncyCastleLib.java | 2 +-
.../crcs/ectester/standalone/libs/CECLibrary.java | 31 -----
.../ectester/standalone/libs/JavaECLibrary.java | 86 --------------
.../ectester/standalone/libs/NativeECLibrary.java | 131 +++++++++++++++++++++
.../standalone/libs/ProviderECLibrary.java | 90 ++++++++++++++
src/cz/crcs/ectester/standalone/libs/SunECLib.java | 2 +-
.../crcs/ectester/standalone/libs/TomcryptLib.java | 16 +++
src/cz/crcs/ectester/standalone/libs/native.h | 21 ++++
12 files changed, 272 insertions(+), 126 deletions(-)
delete mode 100644 src/cz/crcs/ectester/standalone/libs/CECLibrary.java
delete mode 100644 src/cz/crcs/ectester/standalone/libs/JavaECLibrary.java
create mode 100644 src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java
create mode 100644 src/cz/crcs/ectester/standalone/libs/ProviderECLibrary.java
create mode 100644 src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
create mode 100644 src/cz/crcs/ectester/standalone/libs/native.h
(limited to 'src/cz/crcs/ectester/standalone/libs/SunECLib.java')
diff --git a/build-standalone.xml b/build-standalone.xml
index 0ba7f93..05dc174 100644
--- a/build-standalone.xml
+++ b/build-standalone.xml
@@ -75,4 +75,9 @@
+
+
+
+
+
diff --git a/nbproject/reader/project.properties b/nbproject/reader/project.properties
index 6cd1760..ac98170 100644
--- a/nbproject/reader/project.properties
+++ b/nbproject/reader/project.properties
@@ -6,7 +6,7 @@ annotation.processing.source.output=${build.generated.sources.dir}/ap-source-out
application.title=ECTesterReader
application.vendor=xsvenda
build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
+build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
diff --git a/nbproject/standalone/project.properties b/nbproject/standalone/project.properties
index 367ec51..868bcfa 100644
--- a/nbproject/standalone/project.properties
+++ b/nbproject/standalone/project.properties
@@ -6,7 +6,7 @@ annotation.processing.source.output=${build.generated.sources.dir}/ap-source-out
application.title=ECTesterStandalone
application.vendor=xsvenda
build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
+build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
index 76b98ce..e36ffcd 100644
--- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
+++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
@@ -10,7 +10,7 @@ import cz.crcs.ectester.standalone.consts.KeyPairGeneratorIdent;
import cz.crcs.ectester.standalone.consts.SignatureIdent;
import cz.crcs.ectester.standalone.libs.BouncyCastleLib;
import cz.crcs.ectester.standalone.libs.ECLibrary;
-import cz.crcs.ectester.standalone.libs.JavaECLibrary;
+import cz.crcs.ectester.standalone.libs.ProviderECLibrary;
import cz.crcs.ectester.standalone.libs.SunECLib;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
@@ -186,8 +186,8 @@ public class ECTesterStandalone {
*
*/
private void generate() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
- if (cfg.selected instanceof JavaECLibrary) {
- JavaECLibrary jlib = (JavaECLibrary) cfg.selected;
+ if (cfg.selected instanceof ProviderECLibrary) {
+ ProviderECLibrary jlib = (ProviderECLibrary) cfg.selected;
KeyPairGeneratorIdent ident = null;
String algo = cli.getOptionValue("generate.type", "EC");
for (KeyPairGeneratorIdent kpIdent : jlib.getKPGs()) {
@@ -241,8 +241,8 @@ public class ECTesterStandalone {
*
*/
private void export() throws NoSuchAlgorithmException, IOException {
- if (cfg.selected instanceof JavaECLibrary) {
- JavaECLibrary jlib = (JavaECLibrary) cfg.selected;
+ if (cfg.selected instanceof ProviderECLibrary) {
+ ProviderECLibrary jlib = (ProviderECLibrary) cfg.selected;
KeyPairGeneratorIdent ident = null;
String algo = cli.getOptionValue("export.type", "EC");
for (KeyPairGeneratorIdent kpIdent : jlib.getKPGs()) {
diff --git a/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
index 73cd197..aaf76be 100644
--- a/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
+++ b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
@@ -5,7 +5,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
/**
* @author Jan Jancar johny@neuromancer.sk
*/
-public class BouncyCastleLib extends JavaECLibrary {
+public class BouncyCastleLib extends ProviderECLibrary {
public BouncyCastleLib() {
super(new BouncyCastleProvider());
diff --git a/src/cz/crcs/ectester/standalone/libs/CECLibrary.java b/src/cz/crcs/ectester/standalone/libs/CECLibrary.java
deleted file mode 100644
index 82a4555..0000000
--- a/src/cz/crcs/ectester/standalone/libs/CECLibrary.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cz.crcs.ectester.standalone.libs;
-
-/**
- * @author Jan Jancar johny@neuromancer.sk
- */
-public abstract class CECLibrary implements ECLibrary {
-
- private String resourcePath;
- private String libname;
-
- public CECLibrary(String resourcePath, String libname) {
- this.resourcePath = resourcePath;
- this.libname = libname;
- }
-
- @Override
- public boolean initialize() {
- // load the library here.
- return false;
- }
-
- @Override
- public String name() {
- return libname;
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
diff --git a/src/cz/crcs/ectester/standalone/libs/JavaECLibrary.java b/src/cz/crcs/ectester/standalone/libs/JavaECLibrary.java
deleted file mode 100644
index 5689b2b..0000000
--- a/src/cz/crcs/ectester/standalone/libs/JavaECLibrary.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cz.crcs.ectester.standalone.libs;
-
-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 java.security.Provider;
-import java.security.Security;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.Function;
-
-/**
- * @author Jan Jancar johny@neuromancer.sk
- */
-public abstract class JavaECLibrary implements ECLibrary {
- private Provider provider;
- private boolean initialized;
-
- public JavaECLibrary(Provider provider) {
- this.provider = provider;
- this.initialized = false;
- }
-
- @Override
- public boolean initialize() {
- try {
- int result = Security.addProvider(provider);
- if (result == -1) {
- provider = Security.getProvider(provider.getName());
- }
- initialized = true;
- } catch (NullPointerException | SecurityException ignored) {
- initialized = false;
- }
- return initialized;
- }
-
- @Override
- public boolean isInitialized() {
- return initialized;
- }
-
- private Set getIdents(String type, Function getter) {
- Set results = new HashSet<>();
- for (Provider.Service service : provider.getServices()) {
- if (service.getType().equals(type)) {
- T id = getter.apply(service.getAlgorithm());
- if (id != null) {
- results.add(id);
- }
- }
- }
- return results;
- }
-
- @Override
- public Set getECKAs() {
- return getIdents("KeyAgreement", KeyAgreementIdent::get);
- }
-
- @Override
- public Set getECSigs() {
- return getIdents("Signature", SignatureIdent::get);
- }
-
- @Override
- public Set getKPGs() {
- return getIdents("KeyPairGenerator", KeyPairGeneratorIdent::get);
- }
-
- @Override
- public String name() {
- return provider.getInfo();
- }
-
- public Provider getProvider() {
- return provider;
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
diff --git a/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java b/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java
new file mode 100644
index 0000000..40691e6
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/NativeECLibrary.java
@@ -0,0 +1,131 @@
+package cz.crcs.ectester.standalone.libs;
+
+import cz.crcs.ectester.standalone.consts.KeyAgreementIdent;
+import cz.crcs.ectester.standalone.consts.KeyPairGeneratorIdent;
+import cz.crcs.ectester.standalone.consts.SignatureIdent;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.security.Provider;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author Jan Jancar johny@neuromancer.sk
+ */
+public abstract class NativeECLibrary implements ECLibrary {
+ private ProviderECLibrary loaded;
+ private String resource;
+ private String libname;
+
+ public NativeECLibrary(String resource, String libname) {
+ this.resource = resource;
+ this.libname = libname;
+ }
+
+ @Override
+ public boolean initialize() {
+ try {
+ String suffix;
+ Path appData;
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ suffix = "dll";
+ appData = Paths.get(System.getenv("AppData"));
+ } else {
+ suffix = "so";
+ if (System.getProperty("os.name").startsWith("Linux")) {
+ appData = Paths.get(System.getenv("XDG_DATA_HOME"));
+ if (appData == null) {
+ appData = Paths.get(System.getProperty("user.home"), ".local", "share");
+ }
+ } else {
+ appData = Paths.get(System.getProperty("user.home"), ".local", "share");
+ }
+ }
+ Path libDir = appData.resolve("ECTesterStandalone");
+ File libDirFile = libDir.toFile();
+ Path libPath = libDir.resolve(libname + "." + suffix);
+ File libFile = libPath.toFile();
+
+ URL jarURL = NativeECLibrary.class.getResource("/cz/crcs/ectester/standalone/libs/" + resource + "." + suffix);
+ if (jarURL == null) {
+ return false;
+ }
+ URLConnection jarConnection = jarURL.openConnection();
+
+ boolean write = false;
+ if (libDirFile.isDirectory() && libFile.isFile()) {
+ long jarModified = jarConnection.getLastModified();
+
+ long libModified = Files.getLastModifiedTime(libPath).toMillis();
+ if (jarModified > libModified) {
+ write = true;
+ }
+ } else {
+ libDir.toFile().mkdirs();
+ libFile.createNewFile();
+ write = true;
+ }
+
+ if (write) {
+ Files.copy(jarConnection.getInputStream(), libPath, StandardCopyOption.REPLACE_EXISTING);
+ }
+ jarConnection.getInputStream().close();
+
+ System.load(libPath.toString());
+
+ loaded = new ProviderECLibrary(getProvider());
+ return true;
+ } catch (IOException ignored) {
+
+ }
+ return false;
+ }
+
+ public abstract Provider getProvider();
+
+ @Override
+ public boolean isInitialized() {
+ return loaded != null && loaded.isInitialized();
+ }
+
+ @Override
+ public Set getECKAs() {
+ if (!isInitialized()) {
+ return Collections.emptySet();
+ }
+ return loaded.getECKAs();
+ }
+
+ @Override
+ public Set getECSigs() {
+ if (!isInitialized()) {
+ return Collections.emptySet();
+ }
+ return loaded.getECSigs();
+ }
+
+ @Override
+ public Set getKPGs() {
+ if (!isInitialized()) {
+ return Collections.emptySet();
+ }
+ return loaded.getKPGs();
+ }
+
+ @Override
+ public String name() {
+ return loaded.name();
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+}
diff --git a/src/cz/crcs/ectester/standalone/libs/ProviderECLibrary.java b/src/cz/crcs/ectester/standalone/libs/ProviderECLibrary.java
new file mode 100644
index 0000000..879cc16
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/ProviderECLibrary.java
@@ -0,0 +1,90 @@
+package cz.crcs.ectester.standalone.libs;
+
+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 java.security.Provider;
+import java.security.Security;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * @author Jan Jancar johny@neuromancer.sk
+ */
+public class ProviderECLibrary implements ECLibrary {
+ private Provider provider;
+ private boolean initialized;
+
+ public ProviderECLibrary(Provider provider) {
+ this.provider = provider;
+ this.initialized = false;
+ }
+
+ @Override
+ public boolean initialize() {
+ try {
+ int result = Security.addProvider(provider);
+ if (result == -1) {
+ provider = Security.getProvider(provider.getName());
+ }
+ initialized = true;
+ } catch (NullPointerException | SecurityException ignored) {
+ initialized = false;
+ }
+ return initialized;
+ }
+
+ @Override
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ private Set getIdents(String type, Function getter) {
+ Set results = new HashSet<>();
+ if (!initialized) {
+ return results;
+ }
+
+ for (Provider.Service service : provider.getServices()) {
+ if (service.getType().equals(type)) {
+ T id = getter.apply(service.getAlgorithm());
+ if (id != null) {
+ results.add(id);
+ }
+ }
+ }
+ return results;
+ }
+
+ @Override
+ public Set getECKAs() {
+ return getIdents("KeyAgreement", KeyAgreementIdent::get);
+ }
+
+ @Override
+ public Set getECSigs() {
+ return getIdents("Signature", SignatureIdent::get);
+ }
+
+ @Override
+ public Set getKPGs() {
+ return getIdents("KeyPairGenerator", KeyPairGeneratorIdent::get);
+ }
+
+ @Override
+ public String name() {
+ return provider.getInfo();
+ }
+
+ public Provider getProvider() {
+ return provider;
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+}
diff --git a/src/cz/crcs/ectester/standalone/libs/SunECLib.java b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
index 408908e..b64b740 100644
--- a/src/cz/crcs/ectester/standalone/libs/SunECLib.java
+++ b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
@@ -5,7 +5,7 @@ import sun.security.ec.SunEC;
/**
* @author Jan Jancar johny@neuromancer.sk
*/
-public class SunECLib extends JavaECLibrary {
+public class SunECLib extends ProviderECLibrary {
public SunECLib() {
super(new SunEC());
diff --git a/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
new file mode 100644
index 0000000..31d6812
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
@@ -0,0 +1,16 @@
+package cz.crcs.ectester.standalone.libs;
+
+import java.security.Provider;
+
+/**
+ * @author Jan Jancar johny@neuromancer.sk
+ */
+public class TomcryptLib extends NativeECLibrary {
+
+ public TomcryptLib() {
+ super("tomcrypt", "libtomcrypt");
+ }
+
+ @Override
+ public native Provider getProvider();
+}
diff --git a/src/cz/crcs/ectester/standalone/libs/native.h b/src/cz/crcs/ectester/standalone/libs/native.h
new file mode 100644
index 0000000..979f04a
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/libs/native.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class cz_crcs_ectester_standalone_libs_TomcryptLib */
+
+#ifndef _Included_cz_crcs_ectester_standalone_libs_TomcryptLib
+#define _Included_cz_crcs_ectester_standalone_libs_TomcryptLib
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: cz_crcs_ectester_standalone_libs_TomcryptLib
+ * Method: getProvider
+ * Signature: ()Ljava/security/Provider;
+ */
+JNIEXPORT jobject JNICALL Java_cz_crcs_ectester_standalone_libs_TomcryptLib_getProvider
+ (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--
cgit v1.2.3-70-g09d2
From 03265f4cf09b7bb59c09af722b8f44445a635d83 Mon Sep 17 00:00:00 2001
From: J08nY
Date: Wed, 29 Nov 2017 02:22:30 +0100
Subject: Add listing of supported curves to standalone libs.
---
build-standalone.xml | 4 +--
nbproject/reader/project.properties | 2 +-
nbproject/standalone/project.properties | 2 +-
.../ectester/standalone/ECTesterStandalone.java | 5 +++
.../ectester/standalone/libs/BouncyCastleLib.java | 14 ++++++++
.../crcs/ectester/standalone/libs/ECLibrary.java | 2 ++
src/cz/crcs/ectester/standalone/libs/SunECLib.java | 14 ++++++++
.../crcs/ectester/standalone/libs/TomcryptLib.java | 4 +++
.../standalone/libs/jni/NativeProvider.java | 8 ++---
src/cz/crcs/ectester/standalone/libs/jni/native.h | 8 +++++
.../crcs/ectester/standalone/libs/jni/tomcrypt.c | 41 +++++++++++++---------
11 files changed, 78 insertions(+), 26 deletions(-)
(limited to 'src/cz/crcs/ectester/standalone/libs/SunECLib.java')
diff --git a/build-standalone.xml b/build-standalone.xml
index 300eec8..6e65c67 100644
--- a/build-standalone.xml
+++ b/build-standalone.xml
@@ -76,10 +76,10 @@
-
+
-
+
diff --git a/nbproject/reader/project.properties b/nbproject/reader/project.properties
index d372fd5..21441b3 100644
--- a/nbproject/reader/project.properties
+++ b/nbproject/reader/project.properties
@@ -6,7 +6,7 @@ annotation.processing.source.output=${build.generated.sources.dir}/ap-source-out
application.title=ECTesterReader
application.vendor=xsvenda
build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h,**/*.a
+build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h,**/*.a,**/*.o,**/Makefile
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
diff --git a/nbproject/standalone/project.properties b/nbproject/standalone/project.properties
index 7714914..9fed4c2 100644
--- a/nbproject/standalone/project.properties
+++ b/nbproject/standalone/project.properties
@@ -6,7 +6,7 @@ annotation.processing.source.output=${build.generated.sources.dir}/ap-source-out
application.title=ECTesterStandalone
application.vendor=xsvenda
build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h,**/*.a
+build.classes.excludes=**/*.java,**/*.form,**/*.c,**/*.h,**/*.a,**/*.o,**/Makefile
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
diff --git a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
index de9953a..9fca2b6 100644
--- a/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
+++ b/src/cz/crcs/ectester/standalone/ECTesterStandalone.java
@@ -174,6 +174,11 @@ public class ECTesterStandalone {
if (!eckas.isEmpty()) {
System.out.println("\t\t- Signatures: " + String.join(",", sigs.stream().map(SignatureIdent::getName).collect(Collectors.toList())));
}
+ Set curves = lib.getCurves();
+ if (!curves.isEmpty()) {
+ System.out.println("\t\t- Curves: " + String.join(",", curves));
+ }
+ System.out.println();
}
}
}
diff --git a/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
index aaf76be..c6600f9 100644
--- a/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
+++ b/src/cz/crcs/ectester/standalone/libs/BouncyCastleLib.java
@@ -1,7 +1,12 @@
package cz.crcs.ectester.standalone.libs;
+import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.TreeSet;
+
/**
* @author Jan Jancar johny@neuromancer.sk
*/
@@ -11,4 +16,13 @@ public class BouncyCastleLib extends ProviderECLibrary {
super(new BouncyCastleProvider());
}
+ @Override
+ public Set getCurves() {
+ Set result = new TreeSet<>();
+ Enumeration names = ECNamedCurveTable.getNames();
+ while (names.hasMoreElements()) {
+ result.add((String) names.nextElement());
+ }
+ return result;
+ }
}
diff --git a/src/cz/crcs/ectester/standalone/libs/ECLibrary.java b/src/cz/crcs/ectester/standalone/libs/ECLibrary.java
index 1e73e61..0f81978 100644
--- a/src/cz/crcs/ectester/standalone/libs/ECLibrary.java
+++ b/src/cz/crcs/ectester/standalone/libs/ECLibrary.java
@@ -14,6 +14,8 @@ public interface ECLibrary {
boolean isInitialized();
+ Set getCurves();
+
Set getKAs();
Set getSigs();
diff --git a/src/cz/crcs/ectester/standalone/libs/SunECLib.java b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
index b64b740..3aec842 100644
--- a/src/cz/crcs/ectester/standalone/libs/SunECLib.java
+++ b/src/cz/crcs/ectester/standalone/libs/SunECLib.java
@@ -2,6 +2,9 @@ package cz.crcs.ectester.standalone.libs;
import sun.security.ec.SunEC;
+import java.util.Set;
+import java.util.TreeSet;
+
/**
* @author Jan Jancar johny@neuromancer.sk
*/
@@ -11,4 +14,15 @@ public class SunECLib extends ProviderECLibrary {
super(new SunEC());
}
+ @Override
+ public Set getCurves() {
+ String curves = provider.get("AlgorithmParameters.EC SupportedCurves").toString();
+ String[] split = curves.split("\\|");
+ Set result = new TreeSet<>();
+ for (String curve : split) {
+ String body = curve.split(",")[0].substring(1);
+ result.add(body);
+ }
+ return result;
+ }
}
diff --git a/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
index 49e810c..78db00e 100644
--- a/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
+++ b/src/cz/crcs/ectester/standalone/libs/TomcryptLib.java
@@ -1,6 +1,7 @@
package cz.crcs.ectester.standalone.libs;
import java.security.Provider;
+import java.util.Set;
/**
* @author Jan Jancar johny@neuromancer.sk
@@ -13,4 +14,7 @@ public class TomcryptLib extends NativeECLibrary {
@Override
native Provider createProvider();
+
+ @Override
+ public native Set getCurves();
}
diff --git a/src/cz/crcs/ectester/standalone/libs/jni/NativeProvider.java b/src/cz/crcs/ectester/standalone/libs/jni/NativeProvider.java
index 53f8b3c..a2233e2 100644
--- a/src/cz/crcs/ectester/standalone/libs/jni/NativeProvider.java
+++ b/src/cz/crcs/ectester/standalone/libs/jni/NativeProvider.java
@@ -12,11 +12,9 @@ public abstract class NativeProvider extends Provider {
public NativeProvider(String name, double version, String info) {
super(name, version, info);
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- setup();
- return null;
- }
+ AccessController.doPrivileged((PrivilegedAction