[Pcsclite-cvs-commit] r288 - /trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Fri May 29 10:55:51 UTC 2009


Author: rousseau
Date: Fri May 29 10:55:50 2009
New Revision: 288

URL: http://svn.debian.org/wsvn/muscleplugins/?sc=1&rev=288
Log:
Allocate APDU buffer in RAM instead of EEPROM.

Patch from Joao Pedro
http://archives.neohapsis.com/archives/dev/muscle/2009-q2/0122.html

Modified:
    trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src

Modified: trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src
URL: http://svn.debian.org/wsvn/muscleplugins/trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src?rev=288&op=diff
==============================================================================
--- trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src (original)
+++ trunk/MCardApplet/src/com/musclecard/CardEdge/CardEdge.src Fri May 29 10:55:50 2009
@@ -71,8 +71,12 @@
 
 
 #ifdef WITH_EXT_APDU
-    // Maximum size for the extended APDU buffer
-    private final static short EXT_APDU_BUFFER_SIZE = (short) 512;
+    // Maximum size for the extended APDU buffer for a 2048 bit key:
+    // CLA [1 byte] + INS [1 byte] + P1 [1 byte] + P2 [1 byte] +
+    // LC [3 bytes] + cipher_mode[1 byte] + cipher_direction [1 byte] +
+    // data_location [1 byte] + data_size [2 bytes] + data [256 bytes]
+    // = 268 bytes
+    private final static short EXT_APDU_BUFFER_SIZE = (short) 268;
 #endif
     /* Pin policies constants (OR-ed in var pinPolicies) */
     /** Enable pin size check		*/
@@ -607,7 +611,16 @@
   	    Util.setShort(STD_PUBLIC_ACL, i, (short)0x0000);
 #ifdef WITH_EXT_APDU
 	// Initialize the extended APDU buffer
-	recvBuffer = new byte[EXT_APDU_BUFFER_SIZE];	
+	try {
+   	 // Try to allocate the extended APDU buffer on RAM memory
+	    recvBuffer = JCSystem.makeTransientByteArray((short)EXT_APDU_BUFFER_SIZE,
+                                               JCSystem.CLEAR_ON_DESELECT);
+	} catch (SystemException e) {
+	    // Allocate the extended APDU buffer on EEPROM memory
+	    // This is the fallback method, but its usage is really not recommended
+	    // as after ~ 100000 writes it will kill the EEPROM cells...
+	    recvBuffer = new byte[EXT_APDU_BUFFER_SIZE];
+	}	
 #endif
 
 	setupDone = true;




More information about the Pcsclite-cvs-commit mailing list