FreeCalypso > hg > freecalypso-hwlab
changeset 155:804a5b0797c6
fc-simtool: grcard2-set-puk[12] commands implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Feb 2021 02:34:33 +0000 |
parents | ed34c8b7e2c9 |
children | 6d9d0cfc9ed8 |
files | simtool/dispatch.c simtool/grcard2.c |
diffstat | 2 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/simtool/dispatch.c Sun Feb 07 02:29:07 2021 +0000 +++ b/simtool/dispatch.c Sun Feb 07 02:34:33 2021 +0000 @@ -18,6 +18,7 @@ extern int cmd_grcard1_set_ki(); extern int cmd_grcard1_set_pin(); extern int cmd_grcard2_set_pin(); +extern int cmd_grcard2_set_puk(); extern int cmd_iccid(); extern int cmd_imsi(); extern int cmd_pb_dump(); @@ -73,6 +74,8 @@ {"grcard1-set-pin2", 2, 2, cmd_grcard1_set_pin}, {"grcard2-set-pin1", 1, 1, cmd_grcard2_set_pin}, {"grcard2-set-pin2", 1, 1, cmd_grcard2_set_pin}, + {"grcard2-set-puk1", 1, 1, cmd_grcard2_set_puk}, + {"grcard2-set-puk2", 1, 1, cmd_grcard2_set_puk}, {"iccid", 0, 0, cmd_iccid}, {"imsi", 0, 0, cmd_imsi}, {"pb-dump", 1, 2, cmd_pb_dump},
--- a/simtool/grcard2.c Sun Feb 07 02:29:07 2021 +0000 +++ b/simtool/grcard2.c Sun Feb 07 02:34:33 2021 +0000 @@ -53,3 +53,38 @@ } return(0); } + +cmd_grcard2_set_puk(argc, argv) + char **argv; +{ + u_char cmd[13]; + int rc; + + /* Grcard2 proprietary command APDU */ + cmd[0] = 0xA0; + cmd[1] = 0xD4; + cmd[2] = 0x3B; + switch (argv[0][15]) { + case '1': + cmd[3] = 0x00; + break; + case '2': + cmd[3] = 0x02; + break; + default: + fprintf(stderr, "BUG in grcard2-set-pukN command\n"); + return(-1); + } + cmd[4] = 8; + rc = encode_pin_entry(argv[1], 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); +}