diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 00d127d..2e5482e 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1808,7 +1808,27 @@ pn53x_initiator_target_is_present(struct nfc_device *pnd, const nfc_target *pnt) } else { // Limitation: re-select will lose authentication of already authenticated sector // TODO: buggy when card is removed on Tikitag - if ((ret = pn53x_initiator_select_passive_target_ext(pnd, CHIP_DATA(pnd)->current_target->nm, CHIP_DATA(pnd)->current_target->nti.nai.abtUid, CHIP_DATA(pnd)->current_target->nti.nai.szUidLen, NULL, 300)) == 1) { + uint8_t pbtInitiatorData[12]; + uint8_t szInitiatorData = 0; + switch (CHIP_DATA(pnd)->current_target->nti.nai.szUidLen) { + case 4: + memcpy(pbtInitiatorData, CHIP_DATA(pnd)->current_target->nti.nai.abtUid, 4); + szInitiatorData = 4; + break; + case 7: + pbtInitiatorData[0] = 0x88; + memcpy(&pbtInitiatorData[1], CHIP_DATA(pnd)->current_target->nti.nai.abtUid, 7); + szInitiatorData = 8; + break; + case 10: + pbtInitiatorData[0] = 0x88; + memcpy(&pbtInitiatorData[1], CHIP_DATA(pnd)->current_target->nti.nai.abtUid, 3); + pbtInitiatorData[4] = 0x88; + memcpy(&pbtInitiatorData[5], &CHIP_DATA(pnd)->current_target->nti.nai.abtUid[3], 7); + szInitiatorData = 12; + break; + } + if ((ret = pn53x_initiator_select_passive_target_ext(pnd, CHIP_DATA(pnd)->current_target->nm, pbtInitiatorData, szInitiatorData, NULL, 300)) == 1) { ret = NFC_SUCCESS; } else if ((ret == 0) || (ret == NFC_ETIMEOUT)) { ret = NFC_ETGRELEASED;