Le 13/04/2011 15:20, Viktor TARASOV a écrit :
Hi,

the number of APDUs used by PIV's driver to get the object data can be reduced.

Actually before getting object data, PIV driver tries to get it's size.
For that it reads the first 8 bytes of the object data. Usually card responds 
with '61xx' return code,
that's why one (useless) 'GET RESPONSE' APDU is sended by APDU transmit level 
(in apdu.c).

So, there are two not-necessary APDUs for each getting of the object data .

In proposed patch all object data are read at once into the statically 
allocated buffer.


One more patch for the same purpose.
When read for the first time, store the serial number in the sc_card's  member 
'serialnr'.
Return this value when the following 'GET_SERIAL' card ctls arrive.



Have you any objections?

Kind wishes,
Viktor.



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


--
Viktor Tarasov  <viktor.tara...@opentrust.com>

Index: src/libopensc/card-piv.c
===================================================================
--- src/libopensc/card-piv.c    (révision 5342)
+++ src/libopensc/card-piv.c    (copie de travail)
@@ -1690,6 +1690,10 @@
        size_t templen = sizeof(temp);
 
        SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
+       if (card->serialnr.len)   {
+               *serial = card->serialnr;
+               SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
+       }
 
        /* ensure we've got the PIV selected, and nothing else is in process */
        /* This fixes several problems due to previous incomplete APDUs during 
card detection */
@@ -1737,7 +1741,8 @@
                        }
                }
        }
-      
+
+       card->serialnr = *serial;       
        SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
 }
 
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to