I'm using the following:
- Windows 7 64bit
- JDK 7 64bit
- JRE 7 64bit
The new funny JRE 7 64bit doesn't support Sun PKCS11 anymore (which is inside package 'sun.security.pkcs11'). And the big problem is that the end-users of the product by our company may have installed whatever version of JRE.
So I have to swap up the existing to code in 'Sun PKCS11' to 'IAIK PKCS11 Wrapper'. The wrapper by IAIK works simply this way:
(iaik-wrapper.jar)->(iaik-pkcs11-jni.dll)->(pki-token-driver.dll)
The PKI token driver dynamic link library is provided by the manufacturer of PKI USB token, it has the actual name of 'ca2-v34.dll'. The method to load this native driver is described in programmer's manual as below:
import iaik.pkcs.pkcs11.*;
...
Module pkcs11Driver;
try {
pkcs11Driver = Module.getInstance("ca2-v34.dll"); //<--exception!
pkcs11Driver.initialize(null);
//test
System.out.println(pkcs11Driver.getInfo());
}
catch (Exception ex) {
System.out.println(ex);
}
The exception is raised at the line marked in the code above, with this detail: java.io.IOException: %1 is not a valid Win32 application. ca2-v34.dll
This exception surely means the IAIK library has found the .dll file, but it is not compatible somehow. I'm being stuck at this bottleneck.