[Pcsclite-cvs-commit] PKCS11/src p11_sign.c,1.13,1.14

rousseau@quantz.debian.org rousseau@quantz.debian.org
Fri, 27 Feb 2004 18:25:01 +0100


Update of /cvsroot/muscleapps/PKCS11/src
In directory quantz:/tmp/cvs-serv18404

Modified Files:
	p11_sign.c 
Log Message:
in C_Sign() do not return CKR_ARGUMENTS_BAD if pSignature is NULL but
returns the needed size in *pulSignatureLen. Closes [ #300533 ] C_Sign bug


Index: p11_sign.c
===================================================================
RCS file: /cvsroot/muscleapps/PKCS11/src/p11_sign.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- p11_sign.c	4 Oct 2003 08:30:18 -0000	1.13
+++ p11_sign.c	27 Feb 2004 17:24:59 -0000	1.14
@@ -83,7 +83,7 @@
     MSCCryptInit cryptInit;
     P11_Session *session; // = (P11_Session *)hSession;
     P11_Object *key; // = (P11_Object *)session->sign_key;
-    CK_BYTE *to = 0;
+    CK_BYTE *to = NULL;
     CK_ULONG tlen;
     P11_Slot *slot;
     CK_ULONG slotID;
@@ -107,8 +107,14 @@
 
     if (CKR_ERROR(rv = slot_TokenChanged()))
         rv = CKR_SESSION_HANDLE_INVALID;
-    else if (!pData || !pSignature)
+    else if (!pData || !pulSignatureLen)
         rv = CKR_ARGUMENTS_BAD;
+	else if (pSignature == NULL)
+	{
+		// if pSignature is NULL, return pulSignatureLen with the
+		// right value to allocate pSignature
+		*pulSignatureLen = (key->msc_key->keySize / 8);
+	}
 /*
 	else if (INVALID_SESSION)
         rv = CKR_SESSION_HANDLE_INVALID;