Diff

Differences From Artifact [5ad2713a20]:

To Artifact [8c591e3548]:


  2869   2869   				}
  2870   2870   			}
  2871   2871   
  2872   2872   			/* End transaction */
  2873   2873   			cackey_end_transaction(slot);
  2874   2874   
  2875   2875   			if (respcode == 0x6982 || respcode == 0x6e00) {
  2876         -				CACKEY_DEBUG_PRINTF("Security status not satisified (respcode = 0x%04x).  Returning NEEDLOGIN", (int) respcode);
         2876  +				if (respcode == 0x6E00) {
         2877  +					CACKEY_DEBUG_PRINTF("Got \"WRONG CLASS\", this means we are talking to the wrong object (likely because the card went away) -- resetting");
         2878  +				} else {
         2879  +					CACKEY_DEBUG_PRINTF("Security status not satisified (respcode = 0x%04x).  Returning NEEDLOGIN", (int) respcode);
         2880  +				}
  2877   2881   
  2878   2882   				cackey_mark_slot_reset(slot);
  2879   2883   
  2880   2884   				return(CACKEY_PCSC_E_NEEDLOGIN);
  2881   2885   			}
  2882   2886   
  2883   2887   			if (send_ret == CACKEY_PCSC_E_TOKENABSENT) {
................................................................................
  3072   3076   	}
  3073   3077   
  3074   3078   	/* PIV authentication uses a "key_reference" of 0x80 */
  3075   3079   	pcsc_identities = cackey_read_certs(slot, NULL, &num_certs);
  3076   3080   	if (num_certs > 0 && pcsc_identities != NULL) {
  3077   3081   		switch (pcsc_identities[0].id_type) {
  3078   3082   			case CACKEY_ID_TYPE_PIV:
  3079         -				CACKEY_DEBUG_PRINTF("We recently had a PIV card, so we will attempt to authenticate using the PIV Application key reference");
         3083  +				CACKEY_DEBUG_PRINTF("We have PIV card, so we will attempt to authenticate using the PIV Application key reference");
  3080   3084   
  3081   3085   				key_reference = 0x80;
  3082   3086   				break;
  3083   3087   			default:
  3084   3088   				break;
  3085   3089   		}
  3086   3090   
................................................................................
  4424   4428   
  4425   4429   					if (currslot >= (sizeof(cackey_slots) / sizeof(cackey_slots[0]))) {
  4426   4430   						CACKEY_DEBUG_PRINTF("Found more readers than slots are available!");
  4427   4431   
  4428   4432   						break;
  4429   4433   					}
  4430   4434   
  4431         -					CACKEY_DEBUG_PRINTF("Found reader: %s", pcsc_readers);
         4435  +					CACKEY_DEBUG_PRINTF("Found reader: %s (currslot = %lu)", pcsc_readers, (unsigned long) currslot);
  4432   4436   
  4433   4437   					/* Only update the list of slots if we are actually being asked supply the slot information */
  4434   4438   					if (pSlotList) {
  4435   4439   						if (slot_reset) {
  4436   4440   							cackey_slots[currslot].active = 1;
  4437   4441   							cackey_slots[currslot].internal = 0;
  4438   4442   							cackey_slots[currslot].pcsc_reader = strdup(pcsc_readers);
................................................................................
  4445   4449   								cackey_slots[currslot].token_flags = 0;
  4446   4450   							}
  4447   4451   							cackey_slots[currslot].label = NULL;
  4448   4452   
  4449   4453   							cackey_mark_slot_reset(&cackey_slots[currslot]);
  4450   4454   						}
  4451   4455   					} else {
  4452         -						/* Artificially increase the number of active slots by what will become active */
  4453         -						slot_count++;
         4456  +						if (!cackey_slots[currslot].active) {
         4457  +							/* Artificially increase the number of active slots by what will become active */
         4458  +							CACKEY_DEBUG_PRINTF("Found in-active slot %lu, but it will be active after a reset -- marking as active for accounting purposes", (unsigned long) currslot);
         4459  +
         4460  +							slot_count++;
         4461  +						}
  4454   4462   					}
  4455   4463   					currslot++;
  4456   4464   
  4457   4465   					pcsc_readers += curr_reader_len + 1;
  4458   4466   				}
  4459   4467   
  4460   4468   				for (currslot = 0; currslot < (sizeof(cackey_slots) / sizeof(cackey_slots[0])); currslot++) {
  4461   4469   					if (cackey_slots[currslot].active) {
  4462         -						CACKEY_DEBUG_PRINTF("Found active slot %lu", (unsigned long) currslot);
         4470  +						CACKEY_DEBUG_PRINTF("Found active slot %lu, reader = %s", (unsigned long) currslot, cackey_slots[currslot].pcsc_reader);
  4463   4471   
  4464   4472   						slot_count++;
  4465   4473   					}
  4466   4474   				}
  4467   4475   			} else {
  4468   4476   				CACKEY_DEBUG_PRINTF("Second call to SCardListReaders failed, return %s/%li", CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(scard_listreaders_ret), (long) scard_listreaders_ret);
  4469   4477   			}