FreeCalypso > hg > fc-pcsc-tools
changeset 119:0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 23:42:18 +0000 |
parents | 5d45cde6e4b2 |
children | a98992e9fe82 |
files | uicc/dispatch.c uicc/pins.c |
diffstat | 2 files changed, 114 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/uicc/dispatch.c Fri Feb 19 23:23:13 2021 +0000 +++ b/uicc/dispatch.c Fri Feb 19 23:42:18 2021 +0000 @@ -8,7 +8,10 @@ #include <strings.h> #include <stdlib.h> +extern int cmd_change_pin(); extern int cmd_dir(); +extern int cmd_disable_pin(); +extern int cmd_enable_pin(); extern int cmd_exec(); extern int cmd_iccid(); extern int cmd_readbin(); @@ -19,6 +22,7 @@ extern int cmd_select_isim(); extern int cmd_select_usim(); extern int cmd_sim_resp(); +extern int cmd_unblock_pin(); extern int cmd_update_bin(); extern int cmd_update_bin_imm(); extern int cmd_update_rec(); @@ -36,7 +40,10 @@ int (*func)(); } cmdtab[] = { {"atr", 0, 0, 0, retrieve_atr}, + {"change-pin", 3, 3, 0, cmd_change_pin}, {"dir", 0, 0, 1, cmd_dir}, + {"disable-pin", 2, 2, 0, cmd_disable_pin}, + {"enable-pin", 2, 2, 0, cmd_enable_pin}, {"exec", 1, 1, 0, cmd_exec}, {"exit", 0, 0, 0, good_exit}, {"iccid", 0, 0, 0, cmd_iccid}, @@ -49,6 +56,7 @@ {"select-isim", 0, 0, 0, cmd_select_isim}, {"select-usim", 0, 0, 0, cmd_select_usim}, {"sim-resp", 0, 0, 1, cmd_sim_resp}, + {"unblock-pin", 3, 3, 0, cmd_unblock_pin}, {"update-bin", 2, 2, 0, cmd_update_bin}, {"update-bin-imm", 2, 2, 0, cmd_update_bin_imm}, {"update-rec", 2, 2, 0, cmd_update_rec},
--- a/uicc/pins.c Fri Feb 19 23:23:13 2021 +0000 +++ b/uicc/pins.c Fri Feb 19 23:42:18 2021 +0000 @@ -57,3 +57,109 @@ } return(0); } + +cmd_change_pin(argc, argv) + char **argv; +{ + u_char cmd[21]; + int rc; + + /* CHANGE PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x24; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 16; + rc = encode_pin_entry(argv[2], cmd + 5); + if (rc < 0) + return(rc); + rc = encode_pin_entry(argv[3], cmd + 13); + if (rc < 0) + return(rc); + rc = apdu_exchange(cmd, 21); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +} + +cmd_disable_pin(argc, argv) + char **argv; +{ + u_char cmd[13]; + int rc; + + /* DISABLE PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x26; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 8; + rc = encode_pin_entry(argv[2], cmd + 5); + if (rc < 0) + return(rc); + rc = apdu_exchange(cmd, 13); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +} + +cmd_enable_pin(argc, argv) + char **argv; +{ + u_char cmd[13]; + int rc; + + /* ENABLE PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x28; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 8; + rc = encode_pin_entry(argv[2], cmd + 5); + if (rc < 0) + return(rc); + rc = apdu_exchange(cmd, 13); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +} + +cmd_unblock_pin(argc, argv) + char **argv; +{ + u_char cmd[21]; + int rc; + + /* UNBLOCK PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x2C; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 16; + rc = encode_pin_entry(argv[2], cmd + 5); + if (rc < 0) + return(rc); + rc = encode_pin_entry(argv[3], cmd + 13); + if (rc < 0) + return(rc); + rc = apdu_exchange(cmd, 21); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +}