While attending a course about security at university, i had to write a test project using the Cryptlib library and even though the library is clearly thought to be used in a C/C++ environment i was pretty hooked up with Java6 at that time.
So i decided to try to get it to work on my MacBook with Mac OS X Leopard(*) on it, since i knew that java bindings were available.
(*)Edit: i’ve recently tested it on Snow Leopard too and it works the same way.
This is what i did to get it to work (with a little effort):
Get cryptlib 3.3.3 from Peter Gutmann’s website then fire up a shell and type:
$ cd Desktop
$ mkdir cl333
$ unzip -a path/to/downloaded/file/cl333.zip -d cl333/
Using the “unzip” command from shell instead of default Mac OS X decompression utility, is needed to ensure that the text files are converted to the Unix format as explained in the user’s manual.
Then before we go with the usually make command we still have to change a few paths to get the files to point to the correct Java installation, so first of all we enable the Java bindings.
Open the file “misc/config.h”and uncomment the following, at line 43:
#define USE_JAVA
Then open the file “bindings/java_jni.c” and change line 6 to:
#include "/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers/jni.h"
From shell now type:
$ cd cl333/
$ make shared
When it’s done compiling (it takes less than 30 secs on my MacBook), you will see a new file called “libcl.3.3.dylib”. You can move this file anywhere but it’s usually a good practice to put it in your “/usr/local/lib” folder, so from a shell type:
$ mv libcl.3.3.dylib /usr/local/lib/libcl3.3.3.dylib
Note: you may be required to have administrator privileges to do this!
We are almost ready to go but we need to set the correct environment variable to point to the library folder.
To accomplish this, we need to edit the “.profile” file which can be found in our home directory:
$ nano ~/.profile
This will open up the file (which may or may not exists already, it doesn’t really matter) and we just need to add the following line:
LD_LIBRARY_PATH=/usr/local/lib
Ok now we are done!
Open your favourite Java editor (i used NetBeans but it doesn’t matter what you use) and load the library (and bindings) with this line:
System.load("/usr/local/lib/libcl.3.3.dylib");
