On 9/24/2010 6:46 AM, Martin Paljak wrote: > (did not press "reply all") > > Begin forwarded message: > >> From: Martin Paljak<mar...@paljak.pri.ee> >> Date: September 24, 2010 2:43:32 PM GMT+03:00 >> To: Douglas E. Engert<deeng...@anl.gov> >> Subject: Re: [opensc-devel] card->max_recv_size problem >> >> Hello, >> >> On Sep 23, 2010, at 6:28 PM, Douglas E. Engert wrote: >>> I two ran in to a problem with the card-piv.c because of this. >>> It now appears that max_recv_size = 0 implies unlimited length, but >>> should depend on if the card supports extened APDUs and an extended APDU is >>> being requested, >>> What I would think it should mean is 256 for short APDUs and 65536 for >>> extened. >> >> max_recv_size=0 should imply that the card or its driver is not broken and >> can handle Lc=255 and Le=256 for short APDU-s >> If your card driver does not need it, do not use or set card_max_recv size >> at all in the driver. >> >> max_recv_size was introduced and is only set by cards to values< 256, which >> can't handle the default short APDU default lengths for some reason. >> It should not be used by default, and should only be used to limit it values >> below 256. >> >>> Code in card-piv.c which used to have: >>> apdu.le = (card->max_recv_size<= rbuflen)? card->max_recv_size : >>> rbuflen; >>> apdu.resplen = rbuflen; >>> >>> Was changed to: >>> apdu.le = (card->max_recv_size> 0&& card->max_recv_size<= rbuflen)? >>> card->max_recv_size : rbuflen; >>> apdu.resplen = rbuflen; >>> But this would then set apdu.le = rbuflen even if> 256. >> >> Remove the checks from card-piv.c. They should not be needed.
OK, removed the checks for max_recv_size. The code is now just: apdu.le = (rbuflen > 256) ? 256 : rbuflen; When I start writing the driver, the opensc.conf set max_recv_size to 248 but the PIV cards required 256, and all the NIST approved reader could do 256. So the older PIV code used to set max_recv_size = 256; Now that max_recv_size can also have a value of 0, the checks where changed, then changed again. The change today not does not check the value of max_recv_size, as it is defaulted to 0 that means 256. >> >>> Newer cards can support APDUs, (I don't have one to try) so the code >>> will need to be changed again to use extened APDUs. >> >> I don't know a reliable cross-platform method for checking extended APDU >> support in the reader, so that libopensc could match SC_CARD_CAP_APDU_EXT >> against a similar flag in the reader. >> >> The setting should not affect extended APDU-s, if the logic is mistaken >> somewhere, it should be fixed. >> >> -- >> @MartinPaljak.net >> +3725156495 >> > > > -- Douglas E. Engert <deeng...@anl.gov> Argonne National Laboratory 9700 South Cass Avenue Argonne, Illinois 60439 (630) 252-5444 _______________________________________________ opensc-devel mailing list opensc-devel@lists.opensc-project.org http://www.opensc-project.org/mailman/listinfo/opensc-devel