# HG changeset patch # User Mychaela Falconia # Date 1613847948 0 # Node ID d0d1c0b3583167971ac879b654d658a03a5f5109 # Parent 09a66626647d8e31ded85bf047ca7954555c8b9d fc-simtool: add low-level cur-ef-{inval,rehab} commands diff -r 09a66626647d -r d0d1c0b35831 simtool/Makefile --- a/simtool/Makefile Sat Feb 20 04:11:48 2021 +0000 +++ b/simtool/Makefile Sat Feb 20 19:05:48 2021 +0000 @@ -2,11 +2,12 @@ CFLAGS= -O2 -I/usr/include/PCSC -I../libcommon PROG= fc-simtool OBJS= a38.o chv.o chvext.o curfile.o dispatch.o dumpdir.o fplmn.o grcard1.o \ - grcard2.o hlread.o lndwrite.o main.o miscadm.o opldump.o pbcommon.o \ - pbdump.o pberase.o pbrestore.o pbupd_imm.o pbupd_immhex.o plmnsel.o \ - pnndump.o readcmd.o readops.o restorebin.o savebin.o script.o select.o \ - smserase.o smsp_common.o smsp_dump.o smsp_erase.o smsp_restore.o \ - smsp_set.o sstlist.o sysmo.o telsum.o usersum.o writecmd.o writeops.o + grcard2.o hlread.o inval_rehab.o lndwrite.o main.o miscadm.o opldump.o \ + pbcommon.o pbdump.o pberase.o pbrestore.o pbupd_imm.o pbupd_immhex.o \ + plmnsel.o pnndump.o readcmd.o readops.o restorebin.o savebin.o script.o\ + select.o smserase.o smsp_common.o smsp_dump.o smsp_erase.o \ + smsp_restore.o smsp_set.o sstlist.o sysmo.o telsum.o usersum.o \ + writecmd.o writeops.o LIBS= ../libcommon/libcommon.a INSTBIN=/opt/freecalypso/bin diff -r 09a66626647d -r d0d1c0b35831 simtool/dispatch.c --- a/simtool/dispatch.c Sat Feb 20 04:11:48 2021 +0000 +++ b/simtool/dispatch.c Sat Feb 20 19:05:48 2021 +0000 @@ -84,6 +84,8 @@ extern int cmd_write_iccid(); extern int cmd_write_imsi(); +extern int current_ef_inval(); +extern int current_ef_rehab(); extern int good_exit(); extern int retrieve_atr(); @@ -101,6 +103,8 @@ {"change-chv2", 2, 2, 0, cmd_change_chv}, {"change-pin1", 2, 2, 0, cmd_change_chv}, {"change-pin2", 2, 2, 0, cmd_change_chv}, + {"cur-ef-inval", 0, 0, 0, current_ef_inval}, + {"cur-ef-rehab", 0, 0, 0, current_ef_rehab}, {"disable-chv", 1, 1, 0, cmd_disable_chv}, {"disable-chv1", 1, 1, 0, cmd_disable_chv}, {"disable-pin", 1, 1, 0, cmd_disable_chv}, diff -r 09a66626647d -r d0d1c0b35831 simtool/inval_rehab.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simtool/inval_rehab.c Sat Feb 20 19:05:48 2021 +0000 @@ -0,0 +1,52 @@ +/* + * This module implements the rarely-used INVALIDATE and REHABILITATE + * SIM protocol commands. + */ + +#include +#include +#include "simresp.h" + +current_ef_inval() +{ + u_char cmd[5]; + int rc; + + /* INVALIDATE command APDU */ + cmd[0] = 0xA0; + cmd[1] = 0x04; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + rc = apdu_exchange(cmd, 5); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response to INVALIDATE: %04X\n", + sim_resp_sw); + return(-1); + } + return(0); +} + +current_ef_rehab() +{ + u_char cmd[5]; + int rc; + + /* REHABILITATE command APDU */ + cmd[0] = 0xA0; + cmd[1] = 0x44; + cmd[2] = 0; + cmd[3] = 0; + cmd[4] = 0; + rc = apdu_exchange(cmd, 5); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response to REHABILITATE: %04X\n", + sim_resp_sw); + return(-1); + } + return(0); +}