Hello,

When using libp11 to wrap around the AET SafeSign PKCS#11 library, C_GetInfo
fails with CKR_MUTEX_BAD. This is because an empty CK_C_INITIALIZE_ARGS
structure is passed to C_Initialize.

I made a change in PKCS11_CTX_load so that when no init_args have been set,
no CK_C_INITIALIZE_ARGS is given to C_Initialize.
It should not break any other P11 library loading.

Cheers,
Jonathan
diff -urN libp11.orig//src/p11_load.c libp11.new//src/p11_load.c
--- libp11.orig//src/p11_load.c	2011-06-17 10:54:05.553270923 +0200
+++ libp11.new//src/p11_load.c	2011-06-17 11:53:18.089476019 +0200
@@ -55,7 +55,7 @@
 int PKCS11_CTX_load(PKCS11_CTX * ctx, const char *name)
 {
 	PKCS11_CTX_private *priv = PRIVCTX(ctx);
-	CK_C_INITIALIZE_ARGS args;
+	CK_C_INITIALIZE_ARGS *args = NULL;
 	CK_INFO ck_info;
 	int rv;
 
@@ -70,9 +70,11 @@
 	}
 
 	/* Tell the PKCS11 to initialize itself */
-	memset(&args, 0, sizeof(args));
-	args.pReserved = priv->init_args;
-	rv = priv->method->C_Initialize(&args);
+	if (priv->init_args != NULL) {
+		args = (CK_C_INITIALIZE_ARGS *) calloc(1, sizeof(CK_C_INITIALIZE_ARGS));
+		args->pReserved = priv->init_args;
+	}
+	rv = priv->method->C_Initialize(args);
 	if (rv && rv != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
 		PKCS11err(PKCS11_F_PKCS11_CTX_LOAD, rv);
 		return -1;
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to