diff --git a/.gitignore b/.gitignore
index 0283abf..0354169 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,8 @@
+#Maven build result directory
target/
+#binary objects
*.o
+#Eclipse project files
+/.settings
+/.classpath
+/.project
diff --git a/README b/README
index a800da6..3194c3c 100644
--- a/README
+++ b/README
@@ -15,6 +15,16 @@ Java implementation of scrypt
http://groups.google.com/group/lambdaworks-oss
lambdaworks-oss@googlegroups.com
+System prefrences
+ Two preferences are available :
+ - com.lambdaworks.crypto.SCrypt.disableNative : if set to "true" will
+ completely disable the native optimizations (regardless of other preferences)
+ - com.lambdaworks.crypto.SCrypt.nativeLib : allows to define the path to
+ the native library
+
+ eg.
+ java -Dcom.lambdaworks.crypto.SCrypt.disableNative=true MainClass
+ java -Dcom.lambdaworks.crypto.SCrypt.nativeLib=/path/to/the/native/lib.so MainClass
Usage
com.lambdaworks.crypto.SCryptUtil implements a modified version of MCF,
@@ -50,7 +60,8 @@ Maven Artifacts
com.lambdaworks
scrypt
- 1.3.3
+ 1.3.4-SNAPSHOT
+ PRIVATE
Native Code Implementation
diff --git a/pom.xml b/pom.xml
index c20b2a8..7949c34 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.lambdaworks
scrypt
- 1.3.3
+ 1.3.4-SNAPSHOT
jar
@@ -58,21 +58,6 @@
-
- org.apache.maven.plugins
- maven-jarsigner-plugin
- 1.2
-
-
- sign
- verify
-
- sign
-
-
-
-
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -80,7 +65,7 @@
false
- -Xmx2G -Xms512M
+ -Xmx2G -Xms512M -XX:MaxHeapSize=256m
@@ -101,6 +86,31 @@
+
+
+
+
+ sign
+
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jarsigner-plugin
+ 1.2
+
+
+ sign
+ verify
+
+ sign
+
+
+
+
org.apache.maven.plugins
@@ -118,6 +128,26 @@
+
+
+ privateClassif
+
+ false
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.3.2
+
+ PRIVATE
+
+
+
+
+
+
UTF-8
diff --git a/src/main/java/com/lambdaworks/crypto/SCrypt.java b/src/main/java/com/lambdaworks/crypto/SCrypt.java
index 6274238..a0fda1c 100644
--- a/src/main/java/com/lambdaworks/crypto/SCrypt.java
+++ b/src/main/java/com/lambdaworks/crypto/SCrypt.java
@@ -24,8 +24,37 @@ public class SCrypt {
private static final boolean native_library_loaded;
static {
- LibraryLoader loader = LibraryLoaders.loader();
- native_library_loaded = loader.load("scrypt", true);
+ if (Boolean.getBoolean("com.lambdaworks.crypto.SCrypt.disableNative")) {
+ // User want's pure java impl ?! ... Ok let's do so.
+ native_library_loaded = false;
+ } else {
+ // Path to the native lib (if provided)
+ String libPath = System
+ .getProperty("com.lambdaworks.crypto.SCrypt.nativeLib");
+ // trim to null
+ if (libPath != null) {
+ libPath = libPath.trim();
+ if (libPath.length() == 0) {
+ libPath = null;
+ }
+ }
+ if (libPath == null) {
+ // automatic library loading
+ LibraryLoader loader = LibraryLoaders.loader();
+ native_library_loaded = loader.load("scrypt", true);
+ } else {
+ // User wants to use a specific location / SystemLibraryLoader
+ boolean sucessfullyLoaded = false;
+ try {
+ System.load(libPath);
+ sucessfullyLoaded = true;
+ } catch (Exception e) {
+ sucessfullyLoaded = false;
+ e.printStackTrace();
+ }
+ native_library_loaded = sucessfullyLoaded;
+ }
+ }
}
/**