comparison uicc/pins.c @ 118:5d45cde6e4b2

fc-uicc-tool: verify-pin command family implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 23:23:13 +0000
parents simtool/chvext.c@ae3342497fea
children 0ac0aee0df11
comparison
equal deleted inserted replaced
117:b89bc690dec4 118:5d45cde6e4b2
1 /*
2 * This module implements the standard set of commands for working
3 * with UICC PINs; because all of these commands take a user-specified
4 * P2 key ID, they should work with ADM PINs as well.
5 */
6
7 #include <sys/types.h>
8 #include <stdio.h>
9 #include "simresp.h"
10
11 cmd_verify_pin(argc, argv)
12 char **argv;
13 {
14 u_char cmd[13];
15 int rc;
16
17 /* VERIFY PIN command APDU */
18 cmd[0] = 0x00;
19 cmd[1] = 0x20;
20 cmd[2] = 0x00;
21 cmd[3] = strtoul(argv[1], 0, 0);
22 cmd[4] = 8;
23 rc = encode_pin_entry(argv[2], cmd + 5);
24 if (rc < 0)
25 return(rc);
26 rc = apdu_exchange(cmd, 13);
27 if (rc < 0)
28 return(rc);
29 if (sim_resp_sw != 0x9000) {
30 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
31 return(-1);
32 }
33 return(0);
34 }
35
36 cmd_verify_hex(argc, argv)
37 char **argv;
38 {
39 u_char cmd[13];
40 int rc;
41
42 /* VERIFY PIN command APDU */
43 cmd[0] = 0x00;
44 cmd[1] = 0x20;
45 cmd[2] = 0x00;
46 cmd[3] = strtoul(argv[1], 0, 0);
47 cmd[4] = 8;
48 rc = decode_hex_data_from_string(argv[2], cmd + 5, 8, 8);
49 if (rc < 0)
50 return(rc);
51 rc = apdu_exchange(cmd, 13);
52 if (rc < 0)
53 return(rc);
54 if (sim_resp_sw != 0x9000) {
55 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
56 return(-1);
57 }
58 return(0);
59 }