FreeCalypso > hg > fc-pcsc-tools
view simtool/plmnsel.c @ 74:8562d8508cf2
grcard2-set-{adm,super}-hex commands implemented
It appears that GrcardSIM2 cards allow arbitrary 64-bit keys
for ADM and SUPER ADM, not necessarily consisting of ASCII digits
like the specs require for standard PIN and PUK, and pySim-prog.py
in fact sets the ADM key to 4444444444444444 in hex by default,
which is not an ASCII digit string. If the cards allow such keys,
we need to support them too.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 16 Feb 2021 04:10:36 +0000 |
parents | 4eb447be01c0 |
children | d2e800abd257 |
line wrap: on
line source
/* * This module implements commands for working with EF_PLMNsel. */ #include <sys/types.h> #include <stdio.h> #include "simresp.h" #include "curfile.h" #include "file_id.h" static select_ef_plmnsel() { int rc; rc = select_op(DF_GSM); if (rc < 0) return(rc); rc = select_op(EF_PLMNsel); if (rc < 0) return(rc); rc = parse_ef_select_response(); if (rc < 0) return(rc); if (curfile_structure != 0x00) { fprintf(stderr, "error: EF_PLMNsel is not transparent\n"); return(-1); } if (curfile_total_size < 24) { fprintf(stderr, "error: EF_PLMNsel is shorter than spec minimum of 24 bytes\n"); return(-1); } if (curfile_total_size > 255) { fprintf(stderr, "error: EF_PLMNsel is longer than our 255 byte limit\n"); return(-1); } if (curfile_total_size % 3) { fprintf(stderr, "error: EF_PLMNsel length is not a multiple of 3 bytes\n"); return(-1); } return(0); } cmd_plmnsel_dump() { int rc, gap_flag; u_char *dp, *endp; char ascbuf[8]; unsigned idx, linelen; rc = select_ef_plmnsel(); if (rc < 0) return(rc); rc = readbin_op(0, curfile_total_size); if (rc < 0) return(rc); dp = sim_resp_data; endp = sim_resp_data + sim_resp_data_len; gap_flag = 0; linelen = 0; for (idx = 0; dp < endp; idx++, dp += 3) { if (dp[0] == 0xFF && dp[1] == 0xFF && dp[2] == 0xFF) { gap_flag = 1; continue; } if (gap_flag) { if (linelen) { putchar('\n'); linelen = 0; } printf("GAP, continuing at index %u:\n", idx); gap_flag = 0; } if (linelen >= 10) { putchar('\n'); linelen = 0; } decode_plmn_3bytes(dp, ascbuf, 1); if (linelen) putchar(' '); fputs(ascbuf, stdout); linelen++; } if (linelen) putchar('\n'); return(0); }