Check-in [dc38d00e61]
Overview
SHA1:dc38d00e61666d562809526e5a51b255c9e3c04b
Date: 2016-02-26 18:36:30
User: rkeene
Comment:Updated to supply a pioRecvPci parameter to SCardTransmit(), needed by Google's PCSC implementation
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-02-26
18:36
[7272e3d08a] Added additional debugging information for SCardTransmit() being done successfully (user: rkeene, tags: trunk)
18:36
[dc38d00e61] Updated to supply a pioRecvPci parameter to SCardTransmit(), needed by Google's PCSC implementation (user: rkeene, tags: trunk)
18:35
[b512a6df69] Corrected typo in debug message (user: rkeene, tags: trunk)
Changes

Modified cackey.c from [efec2691f8] to [36cd71f6ea].

  1496   1496    *     goes away.
  1497   1497    *
  1498   1498    */
  1499   1499   static cackey_ret cackey_send_apdu(struct cackey_slot *slot, unsigned char class, unsigned char instruction, unsigned char p1, unsigned char p2, unsigned int lc, unsigned char *data, unsigned int le, uint16_t *respcode, unsigned char *respdata, size_t *respdata_len) {
  1500   1500   	uint8_t major_rc, minor_rc;
  1501   1501   	size_t bytes_to_copy, tmp_respdata_len;
  1502   1502   	LPCSCARD_IO_REQUEST pioSendPci;
         1503  +	SCARD_IO_REQUEST pioRecvPci;
  1503   1504   	DWORD xmit_len, recv_len;
  1504   1505   	LONG scard_xmit_ret, scard_reconn_ret;
  1505   1506   	BYTE xmit_buf[1024], recv_buf[1024];
  1506   1507   	int pcsc_connect_ret, pcsc_getresp_ret;
  1507   1508   	int idx;
  1508   1509   
  1509   1510   	CACKEY_DEBUG_PRINTF("Called.");
................................................................................
  1586   1587   	if (class == GSCIS_CLASS_ISO7816 && (instruction == GSCIS_INSTR_VERIFY || instruction == GSCIS_INSTR_CHANGE_REFERENCE) && p1 == 0x00) {
  1587   1588   		CACKEY_DEBUG_PRINTF("Sending APDU: <<censored>>");
  1588   1589   	} else {
  1589   1590   		CACKEY_DEBUG_PRINTBUF("Sending APDU:", xmit_buf, xmit_len);
  1590   1591   	}
  1591   1592   
  1592   1593   	recv_len = sizeof(recv_buf);
  1593         -	scard_xmit_ret = SCardTransmit(slot->pcsc_card, pioSendPci, xmit_buf, xmit_len, NULL, recv_buf, &recv_len);
         1594  +	memcpy(&pioRecvPci, pioSendPci, sizeof(pioRecvPci));
         1595  +	scard_xmit_ret = SCardTransmit(slot->pcsc_card, pioSendPci, xmit_buf, xmit_len, &pioRecvPci, recv_buf, &recv_len);
  1594   1596   
  1595   1597   	if (scard_xmit_ret == SCARD_E_NOT_TRANSACTED) {
  1596   1598   		CACKEY_DEBUG_PRINTF("Failed to send APDU to card (SCardTransmit() = %s/%lx), will ask calling function to retry (not resetting card)...", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_xmit_ret), (unsigned long) scard_xmit_ret);
  1597   1599   
  1598   1600   		/* End Smartcard Transaction */
  1599   1601   		cackey_end_transaction(slot);
  1600   1602   
................................................................................
  1644   1646   					slot->transaction_need_hw_lock = 1;
  1645   1647   					cackey_begin_transaction(slot);
  1646   1648   				}
  1647   1649   
  1648   1650   				CACKEY_DEBUG_PRINTF("Reset successful, retransmitting");
  1649   1651   
  1650   1652   				recv_len = sizeof(recv_buf);
  1651         -				scard_xmit_ret = SCardTransmit(slot->pcsc_card, pioSendPci, xmit_buf, xmit_len, NULL, recv_buf, &recv_len);
         1653  +				memcpy(&pioRecvPci, pioSendPci, sizeof(pioRecvPci));
         1654  +				scard_xmit_ret = SCardTransmit(slot->pcsc_card, pioSendPci, xmit_buf, xmit_len, &pioRecvPci, recv_buf, &recv_len);
  1652   1655   
  1653   1656   				if (scard_xmit_ret != SCARD_S_SUCCESS) {
  1654   1657   					CACKEY_DEBUG_PRINTF("Retransmit failed, returning in failure after disconnecting the card (SCardTransmit = %s/%li)", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_xmit_ret), (long) scard_xmit_ret);
  1655   1658   
  1656   1659   					SCardDisconnect(slot->pcsc_card, SCARD_LEAVE_CARD);
  1657   1660   					slot->pcsc_card_connected = 0;
  1658   1661