Service Développement wrote:
...
According to your various remarks, i have changed the source code like this : - I deleted the added flags field of sc_pkcs15init_dataargs structure and i used the auth_id field in the place of it.
    - I modified the label management.

So the "patch_creation_destruction_data_object.txt" file recapitulate the modifications to have the management of data object creation and destruction.

But i have a last question about destruction of data object. With these modifications, the data objects can be deleted in smartcard. But i did not find the way to delete them from pkcs11 objects list, stored in pkcs15_fw_data :

struct pkcs15_fw_data {
    struct sc_pkcs15_card *        p15_card;
*    struct pkcs15_any_object *    objects[MAX_OBJECTS];*
    unsigned int            num_objects;
    unsigned int            locked;
};

don't know ... perhaps calling pkcs15_create_tokens() again.

Index: src/pkcs15init/pkcs15-cardos.c
===================================================================

hmm, instead of adding a method to delete objects stored in EFs
to every card driver it might make more sense to call
sc_pkcs15init_delete_by_path() directly in sc_pkcs15init_delete_object()
for every object which is stored in a normal EF ...
The attached patch should do this (but it's untested).

Cheers,
Nils
Index: src/pkcs15init/pkcs15-lib.c
===================================================================
--- src/pkcs15init/pkcs15-lib.c	(Revision 3115)
+++ src/pkcs15init/pkcs15-lib.c	(Arbeitskopie)
@@ -2799,21 +2802,24 @@
 {
 	sc_path_t path;
 	struct sc_pkcs15_df *df;
-	int r;
+	int r, stored_in_ef = 0;
 
 	switch(obj->type & SC_PKCS15_TYPE_CLASS_MASK)
 	{
 	case SC_PKCS15_TYPE_PUBKEY:
 		path = ((sc_pkcs15_pubkey_info_t *)obj->data)->path;
+		stored_in_ef = 1;
 		break;
 	case SC_PKCS15_TYPE_PRKEY:
 		path = ((sc_pkcs15_prkey_info_t *)obj->data)->path;
 		break;
 	case SC_PKCS15_TYPE_CERT:
 		path = ((sc_pkcs15_cert_info_t *)obj->data)->path;
+		stored_in_ef = 1;
 		break;
 	case SC_PKCS15_TYPE_DATA_OBJECT:
 		path = ((sc_pkcs15_data_info_t *)obj->data)->path;
+		stored_in_ef = 1;
 		break;
 	default:
 		return SC_ERROR_NOT_SUPPORTED;
@@ -2823,11 +2829,17 @@
 	if ((r = set_so_pin_from_card(p15card, profile)) < 0)
 		return r;
 
-	/* If there's a card-specific way to delete objects, use it.
-	 * Otherwise, just set its label to "deleted" to indicate
-	 * that we can re-used it when we have to make a next
-	 * object in the future. */
-	if (profile->ops->delete_object != NULL) {
+	/* if the object is stored in a normal EF try to
+	 * delete the EF */
+	if (stored_in_ef != 0) {
+		r = sc_pkcs15init_delete_by_path(profile, p15card->card, &path);
+		if (r != SC_SUCCESS)
+			return r;
+	} else if (profile->ops->delete_object != NULL) {
+		/* If there's a card-specific way to delete objects, use it.
+		 * Otherwise, just set its label to "deleted" to indicate
+		 * that we can re-used it when we have to make a next
+		 * object in the future. */
 		r = profile->ops->delete_object(profile, p15card->card,
 			obj->type, obj->data, &path);
 		if (r < 0) {
@@ -2842,8 +2854,7 @@
 			sc_pkcs15_remove_object(p15card, obj);
 			r = sc_pkcs15init_update_any_df(p15card, profile, df, 0);
 		}
-	}
-	else {
+	} else {
 		/* Get the DF we're part of. If there's no DF, fine, we haven't
 		 * been added yet. */
 		if ((df = obj->df) != NULL) {
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to