Check-in [95a0d07484]
Overview
Comment:Updated to pad CAC PIN, as from CoolKey
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:95a0d074849a17d701856ebea8f8ffa9584e059b
User & Date: rkeene on 2010-05-13 18:57:26
Other Links: manifest | tags
Context
2010-05-13
19:23
Removed incorrect comment check-in: a52326f02b user: rkeene tags: trunk
18:57
Updated to pad CAC PIN, as from CoolKey check-in: 95a0d07484 user: rkeene tags: trunk
18:26
Corrected warning check-in: ebb5a279f5 user: rkeene tags: trunk
Changes

Modified cackey.c from [65f29eb7d2] to [4922b8062e].

  1271   1271   		certs = realloc(certs, sizeof(*certs) * (*count));
  1272   1272   	}
  1273   1273   
  1274   1274   	return(certs);
  1275   1275   }
  1276   1276   
  1277   1277   static cackey_ret cackey_login(struct cackey_slot *slot, unsigned char *pin, unsigned long pin_len, int *tries_remaining_p) {
         1278  +	unsigned char cac_pin[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  1278   1279   	uint16_t response_code;
  1279   1280   	int tries_remaining;
  1280   1281   	int send_ret;
  1281   1282   
  1282   1283   	/* Indicate that we do not know about how many tries are remaining */
  1283   1284   	if (tries_remaining_p) {
  1284   1285   		*tries_remaining_p = -1;
  1285   1286   	}
         1287  +
         1288  +	/* Apparently, CAC PINs are *EXACTLY* 8 bytes long -- pad with 0xFF if too short */
         1289  +	if (pin_len >= 8) {
         1290  +		memcpy(cac_pin, pin, 8);
         1291  +	} else {
         1292  +		memcpy(cac_pin, pin, pin_len);
         1293  +	}
  1286   1294   
  1287   1295   	/* Issue PIN Verify */
  1288         -	send_ret = cackey_send_apdu(slot, GSCIS_CLASS_ISO7816, GSCIS_INSTR_VERIFY, 0x00, 0x00, pin_len, pin, 0x00, &response_code, NULL, NULL);
         1296  +	send_ret = cackey_send_apdu(slot, GSCIS_CLASS_ISO7816, GSCIS_INSTR_VERIFY, 0x00, 0x00, sizeof(cac_pin), cac_pin, 0x00, &response_code, NULL, NULL);
  1289   1297   	if (send_ret != CACKEY_PCSC_S_OK) {
  1290   1298   		if ((response_code & 0x63C0) == 0x63C0) {
  1291   1299   			tries_remaining = (response_code & 0xF);
  1292   1300   
  1293   1301   			CACKEY_DEBUG_PRINTF("PIN Verification failed, %i tries remaining", tries_remaining);
  1294   1302   
  1295   1303   			if (tries_remaining_p) {