FreeCalypso > hg > fc-pcsc-tools
view simtool/miscadm.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 | 105aa3d1a494 |
children | 63b640562e21 |
line wrap: on
line source
/* * This module implements write-iccid and write-imsi commands, * available only in the admin programming phase after authenticating * with some card-vendor-dependent ADM key. */ #include <sys/types.h> #include <stdio.h> #include "curfile.h" #include "file_id.h" cmd_write_iccid(argc, argv) char **argv; { int rc; u_char nibbles[20], binrec[10]; rc = parse_decimal_string_arg(argv[1], nibbles, 20); if (rc < 0) return(rc); pack_reversed_nibbles(nibbles, binrec, 10); rc = select_op(FILEID_MF); if (rc < 0) return(rc); rc = select_op(EF_ICCID); if (rc < 0) return(rc); rc = parse_ef_select_response(); if (rc < 0) return(rc); if (curfile_structure != 0x00 || curfile_total_size != 10) { fprintf(stderr, "error: EF_ICCID is not a transparent EF of 10 bytes\n"); return(-1); } return update_bin_op(0, binrec, 10); } cmd_write_imsi(argc, argv) char **argv; { int rc; u_char nibbles[16], binrec[9]; unsigned ndig; rc = parse_decimal_string_arg(argv[1], nibbles + 1, 15); if (rc < 0) return(rc); ndig = rc; if (ndig & 1) nibbles[0] = 9; else nibbles[0] = 1; binrec[0] = (ndig + 2) >> 1; pack_reversed_nibbles(nibbles, binrec + 1, 8); rc = select_op(DF_GSM); if (rc < 0) return(rc); rc = select_op(EF_IMSI); if (rc < 0) return(rc); rc = parse_ef_select_response(); if (rc < 0) return(rc); if (curfile_structure != 0x00 || curfile_total_size != 9) { fprintf(stderr, "error: EF_IMSI is not a transparent EF of 9 bytes\n"); return(-1); } return update_bin_op(0, binrec, 9); }