Java bindings broken?

Alex Taggart <[email protected]>
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
Having a need for a high-level crypto library in my java project, and
seeing cryptlib mentioned on Hacker News, I endeavoured to give it a
try. My ordeal so far:

1. Download cl340.zip and manual.pdf.  Manual gives no direction for
getting the java binding to work beyond a reference to cryptlib.jar.

2. Google finds
http://www.andreagiavatto.com/wordpress/how-to-install-cryptlib-3-3-3-with-java-bindings-on-mac-os-x.html

It's for 3.3.3, but I follow the steps:
- misc/config.h: uncomment #define USE_JAVA
- bindings/java_jni.c: alter location of jni.h
- run: make shared

Result:
cc -c -D__UNIX__ -DNDEBUG -I. -DDATA_LITTLEENDIAN -DHAS_ODBC
-DHAS_LDAP -fPIC -fno-common -DHAS_RECURSIVE_MUTEX -DHAS_ROBUST_MUTEX
-O2 -Wno-pointer-sign -Wno-strict-aliasing -std=gnu99
-fstack-protector -D_FORTIFY_SOURCE=2 -DOSVERSION=1
-fomit-frame-pointer -o ./shared-obj/java_jni.o bindings/java_jni.c
bindings/java_jni.c: In function ‘processStatus’:
bindings/java_jni.c:20: error: ‘cryptlib_crypt_OK’ undeclared (first
use in this function)
bindings/java_jni.c:20: error: (Each undeclared identifier is reported only once
bindings/java_jni.c:20: error: for each function it appears in.)
bindings/java_jni.c: In function ‘processStatusReturnCryptQueryInfo’:
bindings/java_jni.c:59: error: ‘cryptlib_crypt_OK’ undeclared (first
use in this function)
bindings/java_jni.c: In function ‘processStatusReturnCryptObjectInfo’:
bindings/java_jni.c:95: error: ‘cryptlib_crypt_OK’ undeclared (first
use in this function)

Hmph.

3. Look at what 3.3.3 has, since that's what the blog post used. In
cl333/bindings/java_jni.c there are about 1400 lines of #undef/#define
that 3.4.0 doesn't have.  I find #define cryptlib_crypt_OK 0L and add
it to 3.4.0's java_jni.c.  It builds!

4. Made libcl.3.4.dylib and cryptlib.jar available to java, and try
running the code from page 34 of the manual (had to load "cl.3.4"
instead of "cl").

Result:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
cryptlib.crypt.Init()V
	at cryptlib.crypt.Init(Native Method)
	at Cryptlib.main(Cryptlib.java:7)

Find no "Init" in 3.4.0's java_jni.c, but 3.3.3 has the following
(along with about another 1800 lines of functions not present in
3.4.0):
/*
 * Class:     cryptlib_crypt
 * Method:    Init
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_cryptlib_crypt_Init
  (JNIEnv * env, jclass cryptClass)
{
	int status = 0;
	
	status = cryptInit();
	
	processStatus(env, status);
}



5. Screw it, switch to using 3.3.3.  The Init/End java code works!


6. Try adding the "slow poll" initialisation described on page 32 of
the manual by calling the crypt.AddRandom(int) method with the
CRYPT_RANDOM_SLOWPOLL constant... except there is no
CRYPT_RANDOM_SLOWPOLL constant.  Looking at the source in the jar I
see the following:

//CRYPTLIBCONVERTER - NOT SUPPORTED:
//#define CRYPT_RANDOM_FASTPOLL	( -300 )
//CRYPTLIBCONVERTER - NOT SUPPORTED:
//#define CRYPT_RANDOM_SLOWPOLL	( -301 )

Not sure why this is commented out, or why this is "not supported".

Looking in the source for 3.4.0 I find cryptlib/crypt.java has a
RANDOM_SLOWPOLL constant.


7. Give up and write this email.

So far I see a library where the previous release version (3.3.3)
doesn't implement some of the very basic parts mentioned in the
documentation, and where the current release version (3.4.0) doesn't
even compile.  Not to put too fine a point on it, but the quality of
the things I can see and understand (e.g., java, basic release
testing) makes me very concerned about the quality of the things I
can't (e.g., crypto).

I would appreciate some response from the maintainers before sinking
any more time into this.

_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.