From 8cb6a3f94a3dd005a5a4d3f81efd4814f74b4010 Mon Sep 17 00:00:00 2001 From: nils Date: Wed, 21 Apr 2004 20:11:56 +0000 Subject: [PATCH] "--assert-pristine" workaround for Starcos cards (see comment in the patch) git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1776 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/tools/pkcs15-init.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools/pkcs15-init.c b/src/tools/pkcs15-init.c index b8b31351..c2102dc6 100644 --- a/src/tools/pkcs15-init.c +++ b/src/tools/pkcs15-init.c @@ -458,12 +458,20 @@ do_assert_pristine(struct sc_card *card) card->ctx->suppress_errors++; sc_format_path("2F00", &path); + /* Note: in case of an empty starcos card (no MF) the + * card returns SC_ERROR_NOT_ALLOWED when one tries + * to select a file. As no MF implies no pkcs15 structure + * not error should returned in this case. I know + * this isn't really beautiful ... Nils + */ if ((r = sc_select_file(card, &path, NULL)) >= 0 - || r != SC_ERROR_FILE_NOT_FOUND) + || !(r == SC_ERROR_FILE_NOT_FOUND + || (r == SC_ERROR_NOT_ALLOWED && !strcmp(card->name, "StarCOS")))) res = -1; sc_format_path("5015", &path); if ((r = sc_select_file(card, &path, NULL)) >= 0 - || r != SC_ERROR_FILE_NOT_FOUND) + || !(r != SC_ERROR_FILE_NOT_FOUND + || (r == SC_ERROR_NOT_ALLOWED && !strcmp(card->name, "StarCOS")))) res = -1; card->ctx->suppress_errors--;