Hello,

I am sorry to tell that the revision 3028 [1] "Make absolute paths
from all paths read from the PKCS#15 directories by prepending the
DF(PKCS#15) path if necessary." make OpenSC fail with my card.

My card is special and some files (public key files) have a path NULL
and the key is fetched using a Get Data command with the key reference
as parameter.

I patched OpenSC this way:
--- src/libopensc/pkcs15-pubkey.c   (révision 3028)
+++ src/libopensc/pkcs15-pubkey.c   (copie de travail)
@@ -397,7 +397,11 @@ sc_pkcs15_read_pubkey(struct sc_pkcs15_c
   }
   info = (const struct sc_pkcs15_pubkey_info *) obj->data;

-   r = sc_pkcs15_read_file(p15card, &info->path, &data, &len, NULL);
+   if (info->path.len)
+       r = sc_pkcs15_read_file(p15card, &info->path, &data, &len, NULL);
+   else
+       /* path null */
+       r = sc_pkcs15_read_file_key_ref(p15card, info->key_reference, &data, &le
n, NULL);
   if (r < 0) {
       sc_error(p15card->card->ctx, "Failed to read public key file.");
       return r;

And implemented the sc_pkcs15_read_file_key_ref() function which
mainly does a get data command and some ASN.1 manipulation.

With the patch 3028 applied the PATH is not NULL anymore but is
3F005000 now (the path of the parent). So my test on info->path.len
fails and sc_pkcs15_read_file() is used instead of
sc_pkcs15_read_file_key_ref().

I propose the patch:

Index: libopensc/pkcs15.c
===================================================================
--- libopensc/pkcs15.c  (révision 3028)
+++ libopensc/pkcs15.c  (copie de travail)
@@ -1713,7 +1774,11 @@ int sc_pkcs15_hex_string_to_id(const cha

 int sc_pkcs15_make_absolute_path(const sc_path_t *parent, sc_path_t *child)
{
+   /* a 0 length path stays a 0 length path */
+   if (child->len == 0)
+       return SC_SUCCESS;
+
   if (sc_compare_path_prefix(sc_get_mf_path(), child))
-       return 0;
+       return SC_SUCCESS;
   return sc_concatenate_path(child, parent, child);
}

Any objection?

Bye,

[1] 
http://www.opensc-project.org/pipermail/opensc-commits/2006-September/005478.html

--
 Dr. Ludovic Rousseau
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to