As @Nadir alraedy guessed the cryptlib.jar
itself does not contain any native code.
You need to download http://www.cypherpunks.to/~peter/cl343_beta.zip
and unzip it. The Java binding is in bindings/cryptlib.jar
.
To build the native code I believe you can follow the build instructions for Unix in the manual on page 35.
To build the shared library, use make shared
.
Once cryptlib has been built, use make testlib
to build the cryptlib self-test program
testlib, or make stestlib
to build the shared-library self-test program stestlib. This
will run fairly extensive self-tests of cryptlib that you can run after you’ve built it to
make sure that everything is working OK.
edit Following a step-by-step instruction how to build a working library.
# download the archive http://www.cypherpunks.to/~peter/cl343_beta.zip
# extract the archive to any directory
# -a switch to ensure text files not extracted with DOS lineend
unzip -a cl343_beta.zip -d ${CL_HOME}/
# fix executable bits
chmod +x tools/mkhdr.sh
# re-generate the bindings
tools/mkhdr.sh
# modify some source files
# change in ${CL_HOME}/misc/config.h
from /* #define USE_JAVA */
to #define USE_JAVA
# change in ${CL_HOME}/bindings/java_jni.c
from #include <jni.h>
to #include "jni.h"
# copy JDK header files
cd ${CL_HOME}/bindings/
cp ${JAVA_HOME}/include/jni.h .
cp ${JAVA_HOME}/inlcude/linux/jni_md.h .
# build the library
cd ${CL_HOME}/
make
make shared
As test code I took the example from the manual.
import cryptlib.*;
class Cryptlib {
public static void main( String[] args) {
System.loadLibrary( "cl" );
try {
crypt.Init();
//Calls to cryptlib routines
crypt.End();
} catch(CryptException e) {
e.printStackTrace();
}
}
};
copy library files into the directory of Cryptlib.java
.
cd ${dir_of_Cryptlib.java}
cp ${CL_HOME}/bindings/cryptlib.jar .
cp ${CL_HOME}/libcl.so.3.4.3 .
ln -s libcl.so.3.4.3 libcl.so
compile the code
javac -cp cryptlib.jar Cryptlib.java
run the code
java -cp cryptlib.jar:. -Djava.library.path=`pwd` Cryptlib
There will be no output and no exception if the build was successful.