FreeCalypso > hg > fc-pcsc-tools
view simtool/grcard1.c @ 19:72a24b8538eb
meaty function of pb-dump moved back into simtool, out of libcommon
Upon further reflection, I am not going to keep any of the pb-*
commands in the new version of fc-uicc-tool: they are logically
incorrect for UICC/USIM anyway, as they access phonebook files
via old classic SIM paths, rather than their USIM paths.  OTOH,
I am going to implement new SMSP commands in fc-simtool, and I
do not plan to replicate them in fc-uicc-tool either.  Guts of
fc-simtool pb-dump belong in simtool/pbdump.c, not in libcommon,
just like the guts of the future smsp-dump command will belong
in its own respective implementation module.
| author | Mychaela Falconia <falcon@freecalypso.org> | 
|---|---|
| date | Fri, 12 Feb 2021 03:33:26 +0000 | 
| parents | 744fabd6bd3f | 
| children | 
line wrap: on
 line source
/* * This module implements a few special commands for those very few * incredibly lucky people on Earth who have no-longer-available * sysmoSIM-GR1 cards, or any other branded variant of the same card * from Grcard. */ #include <sys/types.h> #include <stdio.h> #include "simresp.h" cmd_grcard1_set_pin(argc, argv) char **argv; { u_char cmd[21]; int rc; /* Grcard1 proprietary command APDU */ cmd[0] = 0x80; cmd[1] = 0xD4; cmd[2] = 0x00; switch (argv[0][15]) { case '1': cmd[3] = 0x01; break; case '2': cmd[3] = 0x02; break; default: fprintf(stderr, "BUG in grcard1-set-pinN command\n"); return(-1); } cmd[4] = 16; rc = encode_pin_entry(argv[1], cmd + 5); if (rc < 0) return(rc); rc = encode_pin_entry(argv[2], 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_grcard1_set_adm(argc, argv) char **argv; { u_char cmd[23]; int rc; /* Grcard1 proprietary command APDU */ cmd[0] = 0x80; cmd[1] = 0xD4; cmd[2] = 0x01; switch (argv[0][15]) { case '1': cmd[3] = 0x04; break; case '2': cmd[3] = 0x05; break; default: fprintf(stderr, "BUG in grcard1-set-admN command\n"); return(-1); } cmd[4] = 18; cmd[5] = 0x03; cmd[6] = 0x00; rc = encode_pin_entry(argv[1], cmd + 7); if (rc < 0) return(rc); rc = encode_pin_entry(argv[2], cmd + 15); if (rc < 0) return(rc); rc = apdu_exchange(cmd, 23); 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_grcard1_set_ki(argc, argv) char **argv; { u_char cmd[21]; int rc; /* Grcard1 proprietary command APDU */ cmd[0] = 0x80; cmd[1] = 0xD4; cmd[2] = 0x02; cmd[3] = 0x00; cmd[4] = 16; rc = decode_hex_data_from_string(argv[1], cmd + 5, 16, 16); 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); }
