Ticket #257 (closed defect: fixed)

NB! Read about ReportingBugs before filing a ticket!

Opened 20 months ago

Last modified 20 months ago

Reading partial objects responds differently when T=0 vs T=1

Reported by: dengert Owned by: opensc-devel@…
Priority: normal Milestone: 0.12.0
Component: opensc Version: 0.11.13
Severity: normal Keywords: get_response partial
Cc: Blocked By:
Blocking:

Description

I ran into a problem when using an older PIV card that uses T=0 with the newer PIV code since 0.11.9. The code attempt to read in the first 8 bytes of an object using the PIV card GET_DATA command. This is done to get the length of the object and test if the object is present, without having to read the full object. (PIV cards do not have a directory, so they only way to determine if an object is present and its size it to start to read it.)

With a T=1 card the Le is sent to the card, and it returns 8 bytes. With the T=0 card, the length is not sent and the card responds with 61XX saying XX bytes of data are available (00 means 256). apdu.c will then use get_response to read XX bytes of data and consider it an error that the card has returned more bytes then can fit in the buffer.

To be consistent between T=0 and T=1, the attached patch changes the logic to only read as many bytes as the caller requested.

The code is exercised by the PIV caching code introduced in 3710 in OpenSC-0.11.9. I believe in the field, all the production PIV cards are using T=1, as I have not seen any bug reports on this.

Please consider adding this fix to 0.11.14 as well as 0.12.

Thanks.

Attachments

apdu.c.short.T0.patch Download (769 bytes) - added by dengert 20 months ago.

Change History

Changed 20 months ago by dengert

comment:1 Changed 20 months ago by dengert

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.