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--;