# HG changeset patch # User Mychaela Falconia # Date 1613778718 0 # Node ID a98992e9fe82b96826e4b5ef222ea2c98c74ebb2 # Parent 0ac0aee0df11f31367bbccadf0d34354d8175c85 fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented diff -r 0ac0aee0df11 -r a98992e9fe82 uicc/dispatch.c --- a/uicc/dispatch.c Fri Feb 19 23:42:18 2021 +0000 +++ b/uicc/dispatch.c Fri Feb 19 23:51:58 2021 +0000 @@ -14,6 +14,8 @@ extern int cmd_enable_pin(); extern int cmd_exec(); extern int cmd_iccid(); +extern int cmd_pin_attempt_cnt(); +extern int cmd_puk_attempt_cnt(); extern int cmd_readbin(); extern int cmd_readef(); extern int cmd_readrec(); @@ -47,6 +49,8 @@ {"exec", 1, 1, 0, cmd_exec}, {"exit", 0, 0, 0, good_exit}, {"iccid", 0, 0, 0, cmd_iccid}, + {"pin-attempt-cnt", 1, 1, 0, cmd_pin_attempt_cnt}, + {"puk-attempt-cnt", 1, 1, 0, cmd_puk_attempt_cnt}, {"quit", 0, 0, 0, good_exit}, {"readbin", 2, 2, 1, cmd_readbin}, {"readef", 1, 1, 1, cmd_readef}, diff -r 0ac0aee0df11 -r a98992e9fe82 uicc/pins.c --- a/uicc/pins.c Fri Feb 19 23:42:18 2021 +0000 +++ b/uicc/pins.c Fri Feb 19 23:51:58 2021 +0000 @@ -163,3 +163,43 @@ } return(0); } + +/* retrieving PIN attempt counters from the card */ + +cmd_pin_attempt_cnt(argc, argv) + char **argv; +{ + u_char cmd[5]; + int rc; + + /* VERIFY PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x20; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 0; + rc = apdu_exchange(cmd, 5); + if (rc < 0) + return(rc); + printf("%04X\n", sim_resp_sw); + return(0); +} + +cmd_puk_attempt_cnt(argc, argv) + char **argv; +{ + u_char cmd[5]; + int rc; + + /* UNBLOCK PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x2C; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 0; + rc = apdu_exchange(cmd, 5); + if (rc < 0) + return(rc); + printf("%04X\n", sim_resp_sw); + return(0); +}