annotate simtool/smsp_common.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 f5a26c1d0b93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements some common functions for working with EF_SMSP.
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "curfile.h"
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "file_id.h"
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 select_ef_smsp()
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 int rc;
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 rc = select_op(DF_TELECOM);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 if (rc < 0)
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 return(rc);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 rc = select_op(EF_SMSP);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (rc < 0)
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(rc);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 rc = parse_ef_select_response();
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (rc < 0)
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return(rc);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (curfile_structure != 0x01) {
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fprintf(stderr, "error: EF_SMSP is not linear fixed\n");
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return(-1);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (curfile_record_len < 28) {
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 fprintf(stderr,
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 "error: EF_SMSP has record length of %u bytes, less than minimum 28\n",
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 curfile_record_len);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return(-1);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return(0);
f5a26c1d0b93 fc-simtool smsp-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }