iso7816_read_binary: do not assume that 6282 is returned with data
Instead of a double check_sw call in case there is no data, assume that a SW is properly sent by the card and do not expose SC_ERROR_FILE_END_REACHED outside of the function (like sc_pkcs15_read_file) This is to facilitate Estonian eID 2018+ that instead of properly returning 6282 with trunkated data, 9000 is returned and next READ BINARY returns 6b00 (invalid p1/p2). The change should be generally harmless for well-behaving cards. Change-Id: I7511ab4841d3bcdf8d6f4a37a9315ea4ac569b10
This commit is contained in:
parent
f070c99b65
commit
ea74308512
|
@ -152,10 +152,8 @@ iso7816_read_binary(struct sc_card *card, unsigned int idx, u8 *buf, size_t coun
|
|||
fixup_transceive_length(card, &apdu);
|
||||
r = sc_transmit_apdu(card, &apdu);
|
||||
LOG_TEST_RET(ctx, r, "APDU transmit failed");
|
||||
if (apdu.resplen == 0)
|
||||
LOG_FUNC_RETURN(ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
|
||||
|
||||
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||
if (r == SC_ERROR_FILE_END_REACHED)
|
||||
LOG_FUNC_RETURN(ctx, apdu.resplen);
|
||||
LOG_TEST_RET(ctx, r, "Check SW error");
|
||||
|
|
Loading…
Reference in New Issue