[Pcsclite-cvs-commit] r1708 - trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest

Ludovic Rousseau rousseau at costa.debian.org
Wed Nov 16 07:57:49 UTC 2005


Author: rousseau
Date: 2005-11-16 07:57:48 +0000 (Wed, 16 Nov 2005)
New Revision: 1708

Modified:
   trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java
Log:
manage a (unsecure) retryCounter


Modified: trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java
===================================================================
--- trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java	2005-11-16 07:24:56 UTC (rev 1707)
+++ trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java	2005-11-16 07:57:48 UTC (rev 1708)
@@ -62,6 +62,8 @@
 
 	private byte pbMemory[];
 	private short pbMemoryLength;
+	private static final byte RETRY_COUNTER_MAX_VALUE = 3;
+	private byte retryCounter = RETRY_COUNTER_MAX_VALUE;
 
     /**
      * readertest default constructor
@@ -305,7 +307,8 @@
                                                & 0x00FF);
               if ( bytesLeft == 0 )
               {
-                ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
+		// send the number of tries left
+                ISOException.throwIt( (short)(0x63C0 + retryCounter) );
               }
               // Get the Data
               index=0;
@@ -323,6 +326,10 @@
                   if ( ((short)(apduBuffer[(short)(ISO7816.OFFSET_CDATA+i)] & 0x00FF))
                          != (short)(i + 0x31))
                   {
+		    // decrement the retry counter
+		    if (retryCounter > 0)
+			retryCounter--;
+
                     short SW = (short) (0x6A00 + i);
                     ISOException.throwIt( SW );
                   }
@@ -331,6 +338,9 @@
                 bytesLeft -= readCount;
                 readCount = apdu.receiveBytes (ISO7816.OFFSET_CDATA);
 
+		// reset the retry counter
+		retryCounter = RETRY_COUNTER_MAX_VALUE;
+
 		// Memorize the command
 		Util.arrayCopy(apduBuffer, (short)(ISO7816.OFFSET_CDATA+index),
 		    pbMemory, (short)(ISO7816.OFFSET_CDATA+index),




More information about the Pcsclite-cvs-commit mailing list