comparison uicc/apdu.c @ 130:f691a19f191d

fc-uicc-tool skeleton started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 04 Feb 2021 00:08:12 +0000
parents
children
comparison
equal deleted inserted replaced
129:2adb802b2a98 130:f691a19f191d
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <pcsclite.h>
5 #include <winscard.h>
6 #include "globals.h"
7
8 apdu_exchange(cmd_apdu, cmd_apdu_len)
9 u_char *cmd_apdu;
10 unsigned cmd_apdu_len;
11 {
12 LONG rv;
13 DWORD dwRecvLength;
14 u_char *sw;
15
16 dwRecvLength = 258;
17 rv = SCardTransmit(hCard, SCARD_PCI_T0, cmd_apdu, cmd_apdu_len, NULL,
18 sim_resp_data, &dwRecvLength);
19 if (rv != SCARD_S_SUCCESS) {
20 fprintf(stderr, "SCardTransmit: %s\n",
21 pcsc_stringify_error(rv));
22 return(-1);
23 }
24 if (dwRecvLength < 2) {
25 fprintf(stderr,
26 "error: SCardTransmit response is shorter than 2 SW bytes\n");
27 return(-1);
28 }
29 sim_resp_data_len = dwRecvLength - 2;
30 sw = sim_resp_data + sim_resp_data_len;
31 sim_resp_sw = (sw[0] << 8) | sw[1];
32 return(0);
33 }