Search code examples
smartcardpkcs#11

Cryptoki C_Initialize fails with code 0x5


I am working on an application that accesses smart cards using PKCS#11. I am able to obtain the entry points that are present in gclib.dll and call them successfully. (I made a call to C_GetFunctionList and obtained the funtion list)

But a call to C_Initialize(NULL_PTR) returns an error code of 0x5. What are the general reasons why this failure might be occurring? I have not been able to find a definite answer why it might fail here.

Thank You.

Edit : I checked procmon at the point where C_Initialize was called and it was trying to look for 2 windows registry entries which were not present. HKLM\SOFTWARE\Wow6432Node\Gemplus\Cryptography\PKCS11\Token HKLM\SOFTWARE\Wow6432Node\Gemplus\Cryptography\PKCS11\4.0


Solution

  • From what I could find online Windows XP (and some other windows operating systems) come with GemSafe drivers pre-installed. The registry entries are also present without adding any additional configurations. https://msdn.microsoft.com/en-us/subscriptions/downloads/cc780058

    But this is not so for Windows 7. I was able to fix this issue by installing Gemalto Classic Client 6.1 instead of trying to install GemSafe and that added the registry entries i needed. http://support.gemalto.com/index.php?id=classic_client