FreeCalypso > hg > fc-sim-tools
comparison simtool/chvext.c @ 10:ddd767f6e15b
fc-simtool ported over
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 14 Mar 2021 07:11:25 +0000 |
| parents | |
| children | 10bfdee30a68 |
comparison
equal
deleted
inserted
replaced
| 9:c9ef9e91dd8e | 10:ddd767f6e15b |
|---|---|
| 1 /* | |
| 2 * This module implements some commands for extended (non-standard) | |
| 3 * CHV-like operations which some cards use for ADM access control. | |
| 4 */ | |
| 5 | |
| 6 #include <sys/types.h> | |
| 7 #include <stdio.h> | |
| 8 #include "simresp.h" | |
| 9 | |
| 10 cmd_verify_ext(argc, argv) | |
| 11 char **argv; | |
| 12 { | |
| 13 u_char cmd[13]; | |
| 14 int rc; | |
| 15 | |
| 16 /* VERIFY CHV command APDU */ | |
| 17 cmd[0] = 0xA0; | |
| 18 cmd[1] = 0x20; | |
| 19 cmd[2] = 0x00; | |
| 20 cmd[3] = strtoul(argv[1], 0, 0); | |
| 21 cmd[4] = 8; | |
| 22 rc = encode_pin_entry(argv[2], cmd + 5); | |
| 23 if (rc < 0) | |
| 24 return(rc); | |
| 25 rc = apdu_exchange(cmd, 13); | |
| 26 if (rc < 0) | |
| 27 return(rc); | |
| 28 if (sim_resp_sw != 0x9000) { | |
| 29 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); | |
| 30 return(-1); | |
| 31 } | |
| 32 return(0); | |
| 33 } | |
| 34 | |
| 35 cmd_verify_hex(argc, argv) | |
| 36 char **argv; | |
| 37 { | |
| 38 u_char cmd[13]; | |
| 39 int rc; | |
| 40 | |
| 41 /* VERIFY CHV command APDU */ | |
| 42 cmd[0] = 0xA0; | |
| 43 cmd[1] = 0x20; | |
| 44 cmd[2] = 0x00; | |
| 45 cmd[3] = strtoul(argv[1], 0, 0); | |
| 46 cmd[4] = 8; | |
| 47 rc = decode_hex_data_from_string(argv[2], cmd + 5, 8, 8); | |
| 48 if (rc < 0) | |
| 49 return(rc); | |
| 50 rc = apdu_exchange(cmd, 13); | |
| 51 if (rc < 0) | |
| 52 return(rc); | |
| 53 if (sim_resp_sw != 0x9000) { | |
| 54 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); | |
| 55 return(-1); | |
| 56 } | |
| 57 return(0); | |
| 58 } |
