# HG changeset patch # User Mychaela Falconia # Date 1614186964 0 # Node ID 13ab44761ea6e3cb8d3555836b24be74fe44fd69 # Parent c13ed9194ecd42b59c0272d2ce543b79720a8727 fc-uicc-tool delete-file implemented diff -r c13ed9194ecd -r 13ab44761ea6 uicc/createfile.c --- a/uicc/createfile.c Wed Feb 24 17:08:37 2021 +0000 +++ b/uicc/createfile.c Wed Feb 24 17:16:04 2021 +0000 @@ -4,7 +4,9 @@ */ #include +#include #include +#include #include #include #include "simresp.h" @@ -46,3 +48,34 @@ } return(0); } + +cmd_delete_file(argc, argv) + char **argv; +{ + u_char apdu[7]; + unsigned file_id; + int rc; + + if (!isxdigit(argv[1][0]) || !isxdigit(argv[1][1]) || + !isxdigit(argv[1][2]) || !isxdigit(argv[1][3]) || argv[1][4]) { + fprintf(stderr, "error: 4-digit hex argument required\n"); + return(-1); + } + file_id = strtoul(argv[1], 0, 16); + /* form command APDU */ + apdu[0] = 0x00; + apdu[1] = 0xE4; + apdu[2] = 0; + apdu[3] = 0; + apdu[4] = 2; + apdu[5] = file_id >> 8; + apdu[6] = file_id; + rc = apdu_exchange(apdu, 7); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +} diff -r c13ed9194ecd -r 13ab44761ea6 uicc/dispatch.c --- a/uicc/dispatch.c Wed Feb 24 17:08:37 2021 +0000 +++ b/uicc/dispatch.c Wed Feb 24 17:16:04 2021 +0000 @@ -12,6 +12,7 @@ extern int cmd_cd(); extern int cmd_change_pin(); extern int cmd_create_file(); +extern int cmd_delete_file(); extern int cmd_dir(); extern int cmd_disable_pin(); extern int cmd_enable_pin(); @@ -49,6 +50,7 @@ {"cd", 1, 1, 0, cmd_cd}, {"change-pin", 3, 3, 0, cmd_change_pin}, {"create-file", 1, 1, 0, cmd_create_file}, + {"delete-file", 1, 1, 0, cmd_delete_file}, {"dir", 0, 0, 1, cmd_dir}, {"disable-pin", 2, 2, 0, cmd_disable_pin}, {"enable-pin", 2, 2, 0, cmd_enable_pin},