Check-in [bf8001bc42]
Overview
SHA1:bf8001bc4214f087a3054e2ad1e867f78e40d563
Date: 2016-02-26 18:42:30
User: rkeene
Comment:Updated to workaround a bug in Google's PCSC implementation where SCardStatus() requires a reader parameter
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-02-26
19:06
[6f34302432] ChromeOS: Renamed files to be more obvious (user: rkeene, tags: trunk)
18:42
[bf8001bc42] Updated to workaround a bug in Google's PCSC implementation where SCardStatus() requires a reader parameter (user: rkeene, tags: trunk)
18:36
[7272e3d08a] Added additional debugging information for SCardTransmit() being done successfully (user: rkeene, tags: trunk)
Changes

Modified cackey.c from [bf13559221] to [3a53605d32].

  3353   3353    *
  3354   3354    */
  3355   3355   static cackey_ret cackey_token_present(struct cackey_slot *slot) {
  3356   3356   	cackey_ret pcsc_connect_ret;
  3357   3357   	DWORD reader_len = 0, state = 0, protocol = 0, atr_len;
  3358   3358   	BYTE atr[MAX_ATR_SIZE];
  3359   3359   	LONG status_ret, scard_reconn_ret;
         3360  +	LPSTR *reader_name;
  3360   3361   
  3361   3362   	CACKEY_DEBUG_PRINTF("Called.");
  3362   3363   
  3363   3364   	if (slot->internal) {
  3364   3365   		CACKEY_DEBUG_PRINTF("Returning token present (internal token)");
  3365   3366   
  3366   3367   		return(CACKEY_PCSC_S_TOKENPRESENT);
................................................................................
  3373   3374   		return(CACKEY_PCSC_E_TOKENABSENT);
  3374   3375   	}
  3375   3376   
  3376   3377   	CACKEY_DEBUG_PRINTF("Calling SCardStatus() to determine card status");
  3377   3378   
  3378   3379   	atr_len = sizeof(atr);
  3379   3380   	status_ret = SCardStatus(slot->pcsc_card, NULL, &reader_len, &state, &protocol, atr, &atr_len);
         3381  + 
         3382  +	if (status_ret == SCARD_E_INSUFFICIENT_BUFFER) {
         3383  +		CACKEY_DEBUG_PRINTF("ScardStatus() returned SCARD_E_INSUFFICIENT_BUFFER, assuming this is a bug (e.g., Google PCSC) implementation and retrying");
         3384  +
         3385  +		atr_len = sizeof(atr);
         3386  +
         3387  +		reader_len = 32768;
         3388  +		reader_name = malloc(reader_len);
         3389  +
         3390  +		status_ret = SCardStatus(slot->pcsc_card, reader_name, &reader_len, &state, &protocol, atr, &atr_len);
         3391  +
         3392  +		free(reader_name);
         3393  +	}
  3380   3394   
  3381   3395   	if (status_ret == SCARD_E_INVALID_HANDLE) {
  3382   3396   		CACKEY_DEBUG_PRINTF("SCardStatus() returned SCARD_E_INVALID_HANDLE, marking as not already connected and trying again");
  3383   3397   		cackey_mark_slot_reset(slot);
  3384   3398   
  3385   3399   		pcsc_connect_ret = cackey_connect_card(slot);
  3386   3400   		if (pcsc_connect_ret != CACKEY_PCSC_S_OK) {