FreeCalypso > hg > fc-pcsc-tools
changeset 220:e07de8a9cedf
fc-simtool grcard2-set-comp128 command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 09 Mar 2021 02:01:27 +0000 |
parents | ac41c42ce806 |
children | e3059d58ec93 |
files | simtool/dispatch.c simtool/grcard2.c |
diffstat | 2 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Sun Mar 07 20:24:05 2021 +0000 +++ b/simtool/dispatch.c Tue Mar 09 02:01:27 2021 +0000 @@ -34,6 +34,7 @@ extern int cmd_grcard1_set_pin(); extern int cmd_grcard2_set_adm5(); extern int cmd_grcard2_set_adm5_hex(); +extern int cmd_grcard2_set_comp128(); extern int cmd_grcard2_set_pin(); extern int cmd_grcard2_set_puk(); extern int cmd_grcard2_set_super(); @@ -164,6 +165,7 @@ {"grcard1-set-pin2", 2, 2, 0, cmd_grcard1_set_pin}, {"grcard2-set-adm5", 1, 1, 0, cmd_grcard2_set_adm5}, {"grcard2-set-adm5-hex", 1, 1, 0, cmd_grcard2_set_adm5_hex}, + {"grcard2-set-comp128", 1, 1, 0, cmd_grcard2_set_comp128}, {"grcard2-set-pin1", 1, 1, 0, cmd_grcard2_set_pin}, {"grcard2-set-pin2", 1, 1, 0, cmd_grcard2_set_pin}, {"grcard2-set-puk1", 1, 1, 0, cmd_grcard2_set_puk},
--- a/simtool/grcard2.c Sun Mar 07 20:24:05 2021 +0000 +++ b/simtool/grcard2.c Tue Mar 09 02:01:27 2021 +0000 @@ -11,6 +11,8 @@ #include <sys/types.h> #include <stdio.h> #include "simresp.h" +#include "curfile.h" +#include "file_id.h" cmd_grcard2_set_pin(argc, argv) char **argv; @@ -181,3 +183,49 @@ } return(0); } + +static +select_ef_weki() +{ + int rc; + + rc = select_op(DF_GSM); + if (rc < 0) + return(rc); + rc = select_op(0x0001); /* proprietary EF */ + if (rc < 0) + return(rc); + rc = parse_ef_select_response(); + if (rc < 0) + return(rc); + if (curfile_structure != 0x00 || curfile_total_size != 35) { + fprintf(stderr, + "error: EF_WEKI is not a transparent EF of 35 bytes\n"); + return(-1); + } + return(0); +} + +cmd_grcard2_set_comp128(argc, argv) + char **argv; +{ + int rc; + unsigned code; + u_char magic_byte; + + if (argv[1][0] < '1' || argv[1][0] > '3' || argv[1][1]) { + fprintf(stderr, "error: invalid argument\n"); + return(-1); + } + code = argv[1][0] - '1'; + rc = select_ef_weki(); + if (rc < 0) + return(rc); + rc = readbin_op(2, 1); + if (rc < 0) + return(rc); + magic_byte = sim_resp_data[0]; + magic_byte &= 0xFC; + magic_byte |= code; + return update_bin_op(2, &magic_byte, 1); +}