Ludovic Rousseau wrote:
On 02/03/06, Nils Larsch <[EMAIL PROTECTED]> wrote:
Nils Larsch wrote:
Ludovic Rousseau wrote:
Hello,
I would like to use the function parse_tokeninfo() wich is defined
static in libopensc/pkcs15.c.
In order to keep the same naming scheme I propose to rename it in
sc_pkcs15_parse_tokeninfo(). I added its definition in
libopensc/pkcs15.h
This function is only used once so the impacts on the code are very
limited.
Patch included.
Any comment or objection?
well parse_tokeninfo() isn't really a function I would like to
export as the return parameter, the sc_pkcs15_card_t object, is
not really suitable for this function. Better would be something
like
typedef struct {
unsigned int version;
the various tokenInfo fields
} sc_token_info_t;
int sc_pkcs15_parse_tokeninfo(sc_token_info_t *ti,
const unsigned char * , size_t );
That would be great.
see attached patch for a experimental implementation
Index: src/libopensc/pkcs15.c
===================================================================
--- src/libopensc/pkcs15.c (Revision 2861)
+++ src/libopensc/pkcs15.c (Arbeitskopie)
@@ -49,19 +49,30 @@
{ NULL, 0, 0, 0, NULL, NULL }
};
-static void parse_tokeninfo(struct sc_pkcs15_card *card, const u8 * buf,
size_t buflen)
+typedef struct {
+ unsigned int version;
+ unsigned int flags;
+ char *label;
+ char *serial_number;
+ char *manufacturer_id;
+ char *last_update;
+ char *preferred_language;
+} sc_pkcs15_tokeninfo_t;
I may also need the supportedAlgorithms field.
This field exists in sc_pkcs15_card_t as:
struct sc_pkcs15_algorithm_info alg_info[1];
but I could not find where this structure is filled or used.
doesn't seem to be used at the moment
I would also need to add the objId field in struct sc_pkcs15_algorithm_info.
yep (and perhaps the other fields as well). Do you have
a card that really sets these tokenInfo values ?
In a similar way (and for the symmetry of the API) the function
sc_pkcs15_encode_tokeninfo() should be changed to use the new type
sc_pkcs15_tokeninfo_t instead of a struct sc_pkcs15_card.
Patch attached. It contains Nils patch with some changes:
- declare sc_pkcs15_tokeninfo_t in src/libopensc/pkcs15.h instead of
src/libopensc/pkcs15.c
- sc_pkcs15_parse_tokeninfo() is not static
- add sc_pkcs15_parse_tokeninfo() in src/libopensc/pkcs15.h
plus my paches:
- change sc_pkcs15_encode_tokeninfo API
- use the new API in sc_pkcs15init_update_tokeninf()
I would like to commit this patch first and then work on other changes.
commit it
Cheers,
Nils
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel