G'day,

Chris Osgood wrote:
C_Destroy is currently not implemented for objects stored on the token.
I think that would be relatively easy to add since it would just require
looking up the OID and calling MSCDeleteObject.

I added the following patch, which seemed to work (at least, my test program ran successfully, and muscleTool showed no objects on the card).

However, now my card returns "token not initialized" when I call C_GetTokenInfo or C_OpenSession. Strangely, other tools such as opensc's pkcs11-tool still work, and I haven't figured out why this is occurring.

So I'm not sure if this patch has any side-effects, but perhaps someone can else can verify whether it works or fails.

-- Geoff


--- libmusclepkcs11/src/p11x_object.c  2003-11-28 19:47:13.000000000 +1000
+++ libmusclepkcs11/src/p11x_object.c  2005-05-25 23:57:57.000000000 +1000
@@ -79,8 +79,33 @@
         if (!object->prev && !object->next)
             st.slots[slotID].objects = 0x00;
 
-        if (object->msc_obj)
+        if (object->msc_obj) 
+        {
+            char obj_id[MSC_MAXSIZE_OBJID];
+
+            /*
+             * The PKCS#11 object is stored under two MSC object IDs. The
+             * first MSC object contains the value of the CKA_VALUE attribute,
+             * and has an ID such as "O0". The second MSC object contains the
+             * values of the remaining PKCS#11 data object attributes (such 
+             * as CKA_APPLICATION, CKA_LABEL, etc) and has an ID such as 
+             * "o0" (that is, the ID of the first object, with the initial
+             * letter converted to lower case).
+             */
+
+            /* Get a copy of the object ID */ 
+            strncpy((char *) obj_id, object->msc_obj->objectID, 
+                    sizeof (obj_id));
+
+            /* Delete the first MSC object (ie, the CKA_VALUE) */        
+            msc_DeleteObject(&st.slots[slotID].conn, (char *) obj_id, 0);
+            
+            /* Delete the second MSC object (ie, the other attributes) */
+            obj_id[0] = tolower(obj_id[0]);
+            msc_DeleteObject(&st.slots[slotID].conn, (char *) obj_id, 0);
+
             free(object->msc_obj);
+        }    

_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to