1

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.

rekire
  • 47,260
  • 30
  • 167
  • 264
jondinham
  • 8,271
  • 17
  • 80
  • 137
  • 2
    It looks like `ca2-v34.dll` is a 32-bit DLL. – user207421 Jan 08 '13 at 11:33
  • the sample usb token manager provided by our manufacturer uses this .dll file for both windows7-32bit and windows7-64bit. i've compared the two files, they are identical, so i believe this dll can be used in both 32bit and 64bit. – jondinham Jan 08 '13 at 13:50
  • 1
    That only means that their software is 32 bit throughout. You can't use a 32-bit DLL from 64 bit software, at least not without building a thunking layer, if that is still possible: we used to have to do that a bit in the 16-32 bit transition. – user207421 Jan 08 '13 at 22:25
  • thank you. yeah you're right, i have to switch temporarily to jre32 to be able to build and run. i will file a request about getting the 64bit driver dll from the manufacturer. – jondinham Jan 09 '13 at 04:26

1 Answers1

1

As noted by EJP in the comments right below the question, ca2-v34.dll is a 32bit dll. The sample usb token manager from the manufacturer is a 32bit-throughout software, so it can load this dll file on both Windows 32 and Windows 64.

The scenario of JRE is different:

  • In case the client computer has JRE 32bit installed, the Java application (.jar file) can run well because the process of JVM is a 32bit process.
  • The other case is that the client computer has JRE 64bit installed, the Java application can not run normally because JVM in this case is a 64bit process, it can load the Java application (.jar file) but fails to load the file 'ca2-v34.dll' due to a reason that this dll file is 32bit dll.
Community
  • 1
  • 1
jondinham
  • 8,271
  • 17
  • 80
  • 137