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

Ludovic Rousseau rousseau at costa.debian.org
Mon Sep 19 14:00:49 UTC 2005


Author: rousseau
Date: 2005-09-19 14:00:49 +0000 (Mon, 19 Sep 2005)
New Revision: 1667

Modified:
   trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java
Log:
add support of VERIFY PIN


Modified: trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java
===================================================================
--- trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java	2005-09-19 12:53:04 UTC (rev 1666)
+++ trunk/HandlerTest/JavaCard/src/org/debian/alioth/pcsclite/readertest/readertest.java	2005-09-19 14:00:49 UTC (rev 1667)
@@ -26,7 +26,6 @@
 public class readertest extends javacard.framework.Applet
 {
     private final static byte CLA_TEST_READER  = (byte)0x80;
-    private final static byte INS_CASE_1_ODD   = (byte)0x20;
     private final static byte INS_CASE_2_ODD   = (byte)0x21;
     private final static byte INS_CASE_3_ODD   = (byte)0x22;
     private final static byte INS_CASE_4_ODD   = (byte)0x23;
@@ -38,6 +37,7 @@
     private final static byte INS_CASE_2_UNBOUND = (byte)0x3A;
     private final static byte INS_CASE_3_UNBOUND = (byte)0x3C;
     private final static byte INS_CASE_4_UNBOUND = (byte)0x3E;
+    private final static byte INS_VERIFY_PIN = (byte)0x20;
 
     private final static byte pcValueTable[]  = {
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
@@ -124,7 +124,6 @@
         switch ( apduBuffer[ISO7816.OFFSET_INS] )
         {
             case INS_CASE_1:
-            case INS_CASE_1_ODD:
               if ( (apduBuffer[ISO7816.OFFSET_LC] & (byte) 0x00FF) != 0 )
               {
                 ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
@@ -288,6 +287,34 @@
               apdu.sendBytesLong(pcValueTable, (short) 0x0000, requiredLe);
             break;
 
+            case INS_VERIFY_PIN:
+              // Incoming Data length
+              bytesLeft = (short) (apduBuffer[ISO7816.OFFSET_LC]
+                                               & 0x00FF);
+              if ( bytesLeft == 0 )
+              {
+                ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
+              }
+              // Get the Data
+              index=0;
+              readCount = apdu.setIncomingAndReceive();
+              while ( bytesLeft > 0 )
+              {
+                for (short i=0; i<readCount; i++)
+                {
+                  if ( ((short)(apduBuffer[(short)(ISO7816.OFFSET_CDATA+i)] & 0x00FF))
+                         != (short)(i + 0x31))
+                  {
+                    short SW = (short) (0x6A00 + i);
+                    ISOException.throwIt( SW );
+                  }
+                  index++;
+                }
+                bytesLeft -= readCount;
+                readCount = apdu.receiveBytes (ISO7816.OFFSET_CDATA);
+              }
+            break;
+
             default:
                 // The INS code is not supported by the dispatcher
                 ISOException.throwIt( ISO7816.SW_INS_NOT_SUPPORTED ) ;




More information about the Pcsclite-cvs-commit mailing list