Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
#Maven build result directory
target/
#binary objects
*.o
#Eclipse project files
/.settings
/.classpath
/.project
13 changes: 12 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ Java implementation of scrypt
http://groups.google.com/group/lambdaworks-oss
[email protected]

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,
Expand Down Expand Up @@ -50,7 +60,8 @@ Maven Artifacts
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.3.3</version>
<version>1.3.4-SNAPSHOT</version>
<classifier>PRIVATE</classifier>
</dependency>

Native Code Implementation
Expand Down
64 changes: 47 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.3.3</version>
<version>1.3.4-SNAPSHOT</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -58,29 +58,14 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>sign</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>

<configuration>
<useFile>false</useFile>
<argLine>-Xmx2G -Xms512M</argLine>
<argLine>-Xmx2G -Xms512M -XX:MaxHeapSize=256m</argLine>
</configuration>

<executions>
Expand All @@ -101,6 +86,31 @@
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>sign</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>sign</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -118,6 +128,26 @@
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>privateClassif</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<classifier>PRIVATE</classifier>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
33 changes: 31 additions & 2 deletions src/main/java/com/lambdaworks/crypto/SCrypt.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

/**
Expand Down