Skip to content
This repository was archived by the owner on Nov 11, 2017. It is now read-only.

Commit d005f36

Browse files
author
Martin Paljak
committed
Minor cleanups
1 parent 88ca044 commit d005f36

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/com/musclecard/CardEdge/CardEdge.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
106106
* Instruction codes *
107107
****************************************/
108108

109-
// Keys' use and management
109+
// Applet initialization
110110
private final static byte INS_SETUP = (byte) 0x2A;
111111

112112
// Keys' use and management
@@ -136,7 +136,6 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
136136
private final static byte INS_LIST_KEYS = (byte) 0x3A;
137137
private final static byte INS_GET_STATUS = (byte) 0x3C;
138138

139-
// TODO: Allocate error return codes
140139

141140
/** There have been memory problems on the card */
142141
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
216215
private final static byte LIST_OPT_RESET = (byte) 0x00;
217216
private final static byte LIST_OPT_NEXT = (byte) 0x01;
218217

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
230221

231222
// Offsets in buffer[] for key generation
232223
private final static short OFFSET_GENKEY_ALG = (short) (ISO7816.OFFSET_CDATA);
@@ -270,7 +261,7 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
270261
private KeyPair[] keyPairs;
271262
private RandomData randomData; // RandomData class instance
272263

273-
// OwnerPIN objects, allocated on demand
264+
// PIN and PUK objects, allocated on demand
274265
private OwnerPIN[] pins, ublk_pins;
275266

276267
// Buffer for storing extended APDUs
@@ -293,8 +284,8 @@ public class CardEdge extends javacard.framework.Applet implements ExtendedLengt
293284
****************************************/
294285

295286
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+
}
298289

299290
public static void install(byte[] bArray, short bOffset, byte bLength) {
300291
CardEdge wal = new CardEdge(bArray, bOffset, bLength);
@@ -303,7 +294,7 @@ public static void install(byte[] bArray, short bOffset, byte bLength) {
303294
wal.register();
304295
else
305296
wal.register(bArray, (short) (bOffset + 1), (byte) (bArray[bOffset]));
306-
} // end of install method
297+
}
307298

308299
public boolean select() {
309300
/*
@@ -317,7 +308,7 @@ public boolean select() {
317308
}
318309
LogOutAll();
319310
return true;
320-
}// end of select method
311+
}
321312

322313
public void deselect() {
323314
// Destroy the IO objects (if they exist)
@@ -395,9 +386,7 @@ public void process(APDU apdu) {
395386
GetChallenge(apdu, buffer);
396387
break;
397388
case INS_EXT_AUTH:
398-
399389
ExternalAuthenticate(apdu, buffer);
400-
401390
break;
402391
case INS_CREATE_OBJ:
403392
CreateObject(apdu, buffer);
@@ -429,7 +418,12 @@ public void process(APDU apdu) {
429418
;
430419
} // end of process method
431420

432-
/********** SETUP FUNCTION *********/
421+
422+
/** Setup APDU - initialize the applet
423+
*
424+
* Incoming data:
425+
* PIN0 len + PIN0 + PUK0 len + PUK0 +
426+
*/
433427
private void setup(APDU apdu, byte[] buffer) {
434428
short bytesLeft = Util.makeShort((byte) 0x00, buffer[ISO7816.OFFSET_LC]);
435429
if (bytesLeft != apdu.setIncomingAndReceive())

0 commit comments

Comments
 (0)