@@ -106,7 +106,7 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
106
106
* Instruction codes *
107
107
****************************************/
108
108
109
- // Keys' use and management
109
+ // Applet initialization
110
110
private final static byte INS_SETUP = (byte ) 0x2A ;
111
111
112
112
// Keys' use and management
@@ -136,7 +136,6 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
136
136
private final static byte INS_LIST_KEYS = (byte ) 0x3A ;
137
137
private final static byte INS_GET_STATUS = (byte ) 0x3C ;
138
138
139
- // TODO: Allocate error return codes
140
139
141
140
/** There have been memory problems on the card */
142
141
private final static short SW_NO_MEMORY_LEFT = ObjectManager .SW_NO_MEMORY_LEFT ;
@@ -216,17 +215,9 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
216
215
private final static byte LIST_OPT_RESET = (byte ) 0x00 ;
217
216
private final static byte LIST_OPT_NEXT = (byte ) 0x01 ;
218
217
219
- private final static byte OPT_DEFAULT = (byte ) 0x00 ; // For every algorithm:
220
- // use default
221
- // JavaCard
222
- // generation
223
- // parameters
224
- private final static byte OPT_RSA_PUB_EXP = (byte ) 0x01 ; // For RSA: provide
225
- // public
226
- // exponent
227
- private final static byte OPT_DSA_GPQ = (byte ) 0x02 ; // For DSA: provide
228
- // p,q,g public key
229
- // parameters
218
+ private final static byte OPT_DEFAULT = (byte ) 0x00 ; // Use JC defaults
219
+ private final static byte OPT_RSA_PUB_EXP = (byte ) 0x01 ; // RSA: provide public exponent
220
+ private final static byte OPT_DSA_GPQ = (byte ) 0x02 ; // DSA: provide p,q,g public key parameters
230
221
231
222
// Offsets in buffer[] for key generation
232
223
private final static short OFFSET_GENKEY_ALG = (short ) (ISO7816 .OFFSET_CDATA );
@@ -270,7 +261,7 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
270
261
private KeyPair [] keyPairs ;
271
262
private RandomData randomData ; // RandomData class instance
272
263
273
- // OwnerPIN objects, allocated on demand
264
+ // PIN and PUK objects, allocated on demand
274
265
private OwnerPIN [] pins , ublk_pins ;
275
266
276
267
// Buffer for storing extended APDUs
@@ -293,8 +284,8 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
293
284
****************************************/
294
285
295
286
private CardEdge (byte [] bArray , short bOffset , byte bLength ) {
296
-
297
- } // end of the constructor
287
+ // FIXME: something should be done already here, not only with setup APDU
288
+ }
298
289
299
290
public static void install (byte [] bArray , short bOffset , byte bLength ) {
300
291
CardEdge wal = new CardEdge (bArray , bOffset , bLength );
@@ -303,7 +294,7 @@ public static void install(byte[] bArray, short bOffset, byte bLength) {
303
294
wal .register ();
304
295
else
305
296
wal .register (bArray , (short ) (bOffset + 1 ), (byte ) (bArray [bOffset ]));
306
- } // end of install method
297
+ }
307
298
308
299
public boolean select () {
309
300
/*
@@ -317,7 +308,7 @@ public boolean select() {
317
308
}
318
309
LogOutAll ();
319
310
return true ;
320
- }// end of select method
311
+ }
321
312
322
313
public void deselect () {
323
314
// Destroy the IO objects (if they exist)
@@ -395,9 +386,7 @@ public void process(APDU apdu) {
395
386
GetChallenge (apdu , buffer );
396
387
break ;
397
388
case INS_EXT_AUTH :
398
-
399
389
ExternalAuthenticate (apdu , buffer );
400
-
401
390
break ;
402
391
case INS_CREATE_OBJ :
403
392
CreateObject (apdu , buffer );
@@ -429,7 +418,12 @@ public void process(APDU apdu) {
429
418
;
430
419
} // end of process method
431
420
432
- /********** SETUP FUNCTION *********/
421
+
422
+ /** Setup APDU - initialize the applet
423
+ *
424
+ * Incoming data:
425
+ * PIN0 len + PIN0 + PUK0 len + PUK0 +
426
+ */
433
427
private void setup (APDU apdu , byte [] buffer ) {
434
428
short bytesLeft = Util .makeShort ((byte ) 0x00 , buffer [ISO7816 .OFFSET_LC ]);
435
429
if (bytesLeft != apdu .setIncomingAndReceive ())
0 commit comments