FreeCalypso > hg > fc-pcsc-tools
view simtool/writecmd.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 | 2071b28cd0c7 |
| children | 702c2c40e51a |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include "curfile.h" cmd_update_bin(argc, argv) char **argv; { unsigned offset, len; u_char data[255]; int rc; offset = strtoul(argv[1], 0, 0); if (offset > 0xFFFF) { fprintf(stderr, "error: offset argument is out of range\n"); return(-1); } rc = read_hex_data_file(argv[2], data); if (rc < 0) return(rc); len = rc; return update_bin_op(offset, data, len); } cmd_update_bin_imm(argc, argv) char **argv; { unsigned offset, len; u_char data[255]; int rc; offset = strtoul(argv[1], 0, 0); if (offset > 0xFFFF) { fprintf(stderr, "error: offset argument is out of range\n"); return(-1); } rc = decode_hex_data_from_string(argv[2], data, 1, 255); if (rc < 0) return(rc); len = rc; return update_bin_op(offset, data, len); } cmd_update_rec(argc, argv) char **argv; { unsigned recno; u_char data[255]; int rc; recno = strtoul(argv[1], 0, 0); if (recno < 1 || recno > 255) { fprintf(stderr, "error: record number argument is out of range\n"); return(-1); } rc = read_hex_data_file(argv[2], data); if (rc < 0) return(rc); if (rc != curfile_record_len) { fprintf(stderr, "error: hex data length != EF record length\n"); return(-1); } return update_rec_op(recno, 0x04, data, curfile_record_len); }
