Hello Martin,

automatically detecting the value of max_recv_size is an option too. The
following snippet of code can manage this. But it depends on the
capabilities of the "get_challenge" operation. For CardOS it could be
enabled, because it results in a value of 300 for CardOS 4.3b with
Omnikey reader. Please note that extended APDU:s are used. Therefore a
detection of this capability is required too.

Regards
Andre

        u8 buf[1024];
        sc_apdu_t apdu;
        sc_format_apdu(card, &apdu, SC_APDU_CASE_2_EXT, 0x84, 0x00, 0x00);

        int i = 0;
        while (1) {
                int j = 0;
                apdu.resplen = i + j;
                while (apdu.resplen == i + j) {
                        if (j == 0)
                                j = 1;
                        else
                                j*=2;
                        apdu.le = i + j;
                        apdu.resp = buf;
                        apdu.resplen = sizeof(buf);
                        sc_transmit_apdu(card, &apdu);
                }
                if (j == 1)
                        break;
                i+=j/2;
        }

        printf("max_recv_size: %d\n", i);


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

Reply via email to