FreeCalypso > hg > fc-pcsc-tools
comparison uicc/createfile.c @ 139:c13ed9194ecd
fc-uicc-tool create-file implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 24 Feb 2021 17:08:37 +0000 |
parents | |
children | 13ab44761ea6 |
comparison
equal
deleted
inserted
replaced
138:58406ead2497 | 139:c13ed9194ecd |
---|---|
1 /* | |
2 * This module implements commands that exercise ETSI TS 102 222 | |
3 * CREATE FILE and DELETE FILE operations. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "simresp.h" | |
11 | |
12 cmd_create_file(argc, argv) | |
13 char **argv; | |
14 { | |
15 u_char apdu[260], inbuf[252], *dp; | |
16 unsigned len1, len2; | |
17 int rc; | |
18 | |
19 rc = decode_hex_data_from_string(argv[1], inbuf, 1, 252); | |
20 if (rc < 0) | |
21 return(rc); | |
22 len1 = rc; | |
23 dp = apdu + 5; | |
24 *dp++ = 0x62; | |
25 if (len1 < 0x80) { | |
26 *dp++ = len1; | |
27 len2 = len1 + 2; | |
28 } else { | |
29 *dp++ = 0x81; | |
30 *dp++ = len1; | |
31 len2 = len1 + 3; | |
32 } | |
33 bcopy(inbuf, dp, len1); | |
34 /* command header */ | |
35 apdu[0] = 0x00; | |
36 apdu[1] = 0xE0; | |
37 apdu[2] = 0; | |
38 apdu[3] = 0; | |
39 apdu[4] = len2; | |
40 rc = apdu_exchange(apdu, len2 + 5); | |
41 if (rc < 0) | |
42 return(rc); | |
43 if (sim_resp_sw != 0x9000) { | |
44 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); | |
45 return(-1); | |
46 } | |
47 return(0); | |
48 } |