Compare commits
No commits in common. "300aec6d85128931fd38e25fb925b26103796c4a" and "0633e5c7671329357c9b030bda1dbc9de94dc28a" have entirely different histories.
300aec6d85
...
0633e5c767
2 changed files with 62 additions and 80 deletions
|
@ -6,9 +6,6 @@ card_connect
|
||||||
// select
|
// select
|
||||||
send_apdu -sc 0 -APDU 00A40400080102030405060809
|
send_apdu -sc 0 -APDU 00A40400080102030405060809
|
||||||
|
|
||||||
// Public Command
|
|
||||||
send_apdu -sc 0 -APDU 80000000
|
|
||||||
|
|
||||||
// Locked Commands
|
// Locked Commands
|
||||||
send_apdu -sc 0 -APDU 8002000002FFFE
|
send_apdu -sc 0 -APDU 8002000002FFFE
|
||||||
|
|
||||||
|
@ -16,14 +13,14 @@ send_apdu -sc 0 -APDU 8002000002FFFE
|
||||||
send_apdu -sc 0 -APDU 802000000431313131
|
send_apdu -sc 0 -APDU 802000000431313131
|
||||||
|
|
||||||
// Still Locked Commands
|
// Still Locked Commands
|
||||||
send_apdu -sc 0 -APDU 8004000000
|
send_apdu -sc 0 -APDU 800400000001
|
||||||
|
|
||||||
// Unlock Card With Correct PIN
|
// Unlock Card With Correct PIN
|
||||||
send_apdu -sc 0 -APDU 802000000431323334
|
send_apdu -sc 0 -APDU 802000000431323334
|
||||||
|
|
||||||
// Now Unlocked Commands
|
// Now Unlocked Commands
|
||||||
send_apdu -sc 0 -APDU 8002000002FFFE
|
send_apdu -sc 0 -APDU 8002000002FFFE
|
||||||
send_apdu -sc 0 -APDU 8004000001
|
send_apdu -sc 0 -APDU 800400000001
|
||||||
|
|
||||||
// Query Author Name
|
// Query Author Name
|
||||||
send_apdu -sc 0 -APDU 80000000
|
send_apdu -sc 0 -APDU 80000000
|
||||||
|
@ -32,8 +29,8 @@ send_apdu -sc 0 -APDU 80000000
|
||||||
send_apdu -sc 0 -APDU 8002000002FFFE
|
send_apdu -sc 0 -APDU 8002000002FFFE
|
||||||
|
|
||||||
// Querying Data
|
// Querying Data
|
||||||
send_apdu -sc 0 -APDU 8004000001
|
send_apdu -sc 0 -APDU 800400000001
|
||||||
send_apdu -sc 0 -APDU 8004000002
|
send_apdu -sc 0 -APDU 800400000002
|
||||||
|
|
||||||
// Triggering Unsupported Instruction Error
|
// Triggering Unsupported Instruction Error
|
||||||
send_apdu -sc 0 -APDU 8001000000
|
send_apdu -sc 0 -APDU 8001000000
|
||||||
|
@ -46,22 +43,7 @@ send_apdu -sc 0 -APDU 80020000150102030405060708090A0B0C0D0E0F101112131415
|
||||||
|
|
||||||
// Querying Incorrect Amount of Bytes
|
// Querying Incorrect Amount of Bytes
|
||||||
send_apdu -sc 0 -APDU 8002000002FFFE
|
send_apdu -sc 0 -APDU 8002000002FFFE
|
||||||
send_apdu -sc 0 -APDU 8004000003
|
send_apdu -sc 0 -APDU 800400000003
|
||||||
|
|
||||||
// De- and re-select applet
|
|
||||||
card_disconnect
|
|
||||||
card_connect
|
|
||||||
send_apdu -sc 0 -APDU 00A40400080102030405060809
|
|
||||||
|
|
||||||
// Exceed maximum of PIN unlock trials
|
|
||||||
send_apdu -sc 0 -APDU 802000000431313131
|
|
||||||
send_apdu -sc 0 -APDU 802000000431313131
|
|
||||||
send_apdu -sc 0 -APDU 802000000431313131
|
|
||||||
|
|
||||||
// De- and re-select applet in locked state
|
|
||||||
card_disconnect
|
|
||||||
card_connect
|
|
||||||
send_apdu -sc 0 -APDU 00A40400080102030405060809
|
|
||||||
|
|
||||||
card_disconnect
|
card_disconnect
|
||||||
release_context
|
release_context
|
||||||
|
|
|
@ -14,7 +14,6 @@ import javacard.framework.*;
|
||||||
*/
|
*/
|
||||||
public class MyApplet extends Applet {
|
public class MyApplet extends Applet {
|
||||||
final static short SW_PIN_VERIFICATION_REQUIRED = 0x6301;
|
final static short SW_PIN_VERIFICATION_REQUIRED = 0x6301;
|
||||||
final static short SW_VERIFICATION_FAILED = 0x6300;
|
|
||||||
final static byte PIN_TRY_LIMIT =(byte)0x03;
|
final static byte PIN_TRY_LIMIT =(byte)0x03;
|
||||||
final static byte MAX_PIN_SIZE =(byte)0x08;
|
final static byte MAX_PIN_SIZE =(byte)0x08;
|
||||||
private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' };
|
private byte[] authorName = new byte[] { 'M', 'a', 'n', 'u', 'e', 'l' };
|
||||||
|
@ -53,6 +52,14 @@ public class MyApplet extends Applet {
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean select() {
|
||||||
|
if (pin.getTriesRemaining() == 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return super.select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void deselect() {
|
public void deselect() {
|
||||||
super.deselect();
|
super.deselect();
|
||||||
pin.reset();
|
pin.reset();
|
||||||
|
@ -69,11 +76,7 @@ public class MyApplet extends Applet {
|
||||||
byte[] buffer = apdu.getBuffer();
|
byte[] buffer = apdu.getBuffer();
|
||||||
|
|
||||||
if (selectingApplet()) {
|
if (selectingApplet()) {
|
||||||
if (pin.getTriesRemaining() == 0) {
|
|
||||||
ISOException.throwIt(SW_VERIFICATION_FAILED);
|
|
||||||
} else {
|
|
||||||
ISOException.throwIt(ISO7816.SW_NO_ERROR);
|
ISOException.throwIt(ISO7816.SW_NO_ERROR);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (buffer[ISO7816.OFFSET_CLA] != (byte)0x80) {
|
if (buffer[ISO7816.OFFSET_CLA] != (byte)0x80) {
|
||||||
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
|
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
|
||||||
|
@ -82,8 +85,8 @@ public class MyApplet extends Applet {
|
||||||
byte instruction = buffer[ISO7816.OFFSET_INS];
|
byte instruction = buffer[ISO7816.OFFSET_INS];
|
||||||
|
|
||||||
switch (instruction) {
|
switch (instruction) {
|
||||||
case 0x02:
|
|
||||||
case 0x04:
|
case 0x04:
|
||||||
|
case 0x02:
|
||||||
authenticationRequired = !pin.isValidated();
|
authenticationRequired = !pin.isValidated();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -124,10 +127,7 @@ public class MyApplet extends Applet {
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x20:
|
||||||
length = apdu.setIncomingAndReceive();
|
length = apdu.setIncomingAndReceive();
|
||||||
|
pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length);
|
||||||
if (!pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length)) {
|
|
||||||
ISOException.throwIt(SW_VERIFICATION_FAILED);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||||
|
|
Loading…
Reference in a new issue