The attached change to card-piv.c is need to recognize a valid PIV card applet. All of the previous test cards would return in response to a SELECT the full AID where as they should have returned the the PIX portion of the AID. The newest test cards are now doing this correctly.
This change will recognize either as a PIV applet. Thanks. -- Douglas E. Engert <[EMAIL PROTECTED]> Argonne National Laboratory 9700 South Cass Avenue Argonne, Illinois 60439 (630) 252-5444
Index: card-piv.c =================================================================== --- card-piv.c (revision 2867) +++ card-piv.c (working copy) @@ -440,10 +440,12 @@ if (pix != NULL ) { sc_debug(card->ctx,"found PIX"); + /* early cards returned full AID, rather then just the pix */ for (i = 0; piv_aids[i].len_short != 0; i++) { - if (pixlen >= piv_aids[i].len_short && + if ((pixlen >= 6 && memcmp(pix, piv_aids[i].value + 5, 6) == 0) + || ((pixlen >= piv_aids[i].len_short && memcmp(pix, piv_aids[i].value, - piv_aids[i].len_short) == 0) { + piv_aids[i].len_short) == 0))) { if (card->type > SC_CARD_TYPE_PIV_II_BASE && card->type < SC_CARD_TYPE_PIV_II_BASE+1000 && card->type == piv_aids[i].enumtag) { @@ -637,6 +639,11 @@ r = piv_get_data(card, priv->selected_obj, &rbuf, &rbuflen); if (r >=0) { + /* if tag is 0, assume card is telling us no object on card */ + if (rbuf[0] == '0') { + r = SC_ERROR_FILE_NOT_FOUND; + goto err; + } sc_debug(card->ctx, "DEE rbuf=%p,rbuflen=%d,",rbuf, rbuflen); body = (u8 *) sc_asn1_find_tag(card->ctx, rbuf, rbuflen, 0x53, &bodylen); if (body == NULL) { @@ -680,6 +687,7 @@ break; } } +err: if (rbuf) free(rbuf); SC_FUNC_RETURN(card->ctx, 1, r);
_______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel