Make use of the now available Tk info
This commit is contained in:
parent
cbca45e21c
commit
ffe50562dd
5 changed files with 17 additions and 9 deletions
|
@ -320,13 +320,21 @@ main (int argc, char *argv[])
|
||||||
// | +-------- DR=2,4 DS=2,4 => supports 106, 212 & 424bps in both directions
|
// | +-------- DR=2,4 DS=2,4 => supports 106, 212 & 424bps in both directions
|
||||||
// +----------- TA,TB,TC, FSCI=5 => FSC=64
|
// +----------- TA,TB,TC, FSCI=5 => FSC=64
|
||||||
// It seems hazardous to tell we support NAD if the tag doesn't support NAD but I don't know how to disable it
|
// It seems hazardous to tell we support NAD if the tag doesn't support NAD but I don't know how to disable it
|
||||||
// PC/SC pseudo-ATR = 3B 80 80 01 01
|
// PC/SC pseudo-ATR = 3B 80 80 01 01 if there is no historical bytes
|
||||||
|
|
||||||
|
// Creates ATS and copy max 48 bytes of Tk:
|
||||||
|
byte_t * pbtTk;
|
||||||
|
size_t szTk;
|
||||||
|
pbtTk = iso14443a_locate_historical_bytes (ntEmulatedTarget.nti.nai.abtAts, ntEmulatedTarget.nti.nai.szAts, &szTk);
|
||||||
|
szTk = (szTk > 48) ? 48 : szTk;
|
||||||
|
byte_t pbtTkt[48];
|
||||||
|
memcpy(pbtTkt, pbtTk, szTk);
|
||||||
ntEmulatedTarget.nti.nai.abtAts[0] = 0x75;
|
ntEmulatedTarget.nti.nai.abtAts[0] = 0x75;
|
||||||
ntEmulatedTarget.nti.nai.abtAts[1] = 0x33;
|
ntEmulatedTarget.nti.nai.abtAts[1] = 0x33;
|
||||||
ntEmulatedTarget.nti.nai.abtAts[2] = 0x92;
|
ntEmulatedTarget.nti.nai.abtAts[2] = 0x92;
|
||||||
ntEmulatedTarget.nti.nai.abtAts[3] = 0x03;
|
ntEmulatedTarget.nti.nai.abtAts[3] = 0x03;
|
||||||
ntEmulatedTarget.nti.nai.szAtsLen = 4;
|
ntEmulatedTarget.nti.nai.szAtsLen = 4 + szTk;
|
||||||
//FIXME we could actually emulate also the historical bytes of the tag once libnfc API supports it...
|
memcpy(&(ntEmulatedTarget.nti.nai.abtAts[4]), pbtTkt, szTk);
|
||||||
|
|
||||||
printf("We will emulate:\n");
|
printf("We will emulate:\n");
|
||||||
print_nfc_iso14443a_info (ntEmulatedTarget.nti.nai);
|
print_nfc_iso14443a_info (ntEmulatedTarget.nti.nai);
|
||||||
|
|
|
@ -206,7 +206,7 @@ typedef struct {
|
||||||
size_t szUidLen;
|
size_t szUidLen;
|
||||||
byte_t abtUid[10];
|
byte_t abtUid[10];
|
||||||
size_t szAtsLen;
|
size_t szAtsLen;
|
||||||
byte_t abtAts[36];
|
byte_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
|
||||||
} nfc_iso14443a_info_t;
|
} nfc_iso14443a_info_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -107,7 +107,7 @@ extern "C" {
|
||||||
/* Misc. functions */
|
/* Misc. functions */
|
||||||
NFC_EXPORT void iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc);
|
NFC_EXPORT void iso14443a_crc (byte_t * pbtData, size_t szLen, byte_t * pbtCrc);
|
||||||
NFC_EXPORT void append_iso14443a_crc (byte_t * pbtData, size_t szLen);
|
NFC_EXPORT void append_iso14443a_crc (byte_t * pbtData, size_t szLen);
|
||||||
NFC_EXPORT byte_t * iso14443a_extract_historical_bytes (byte_t * pbtAts, size_t szAts, size_t * pszHB);
|
NFC_EXPORT byte_t * iso14443a_locate_historical_bytes (byte_t * pbtAts, size_t szAts, size_t * pszTk);
|
||||||
NFC_EXPORT const char *nfc_version (void);
|
NFC_EXPORT const char *nfc_version (void);
|
||||||
|
|
||||||
/* Common device-level errors */
|
/* Common device-level errors */
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ pn53x_target_init (nfc_device_t * pnd, const nfc_target_mode_t ntm, nfc_target_t
|
||||||
pbtMifareParams = abtMifareParams;
|
pbtMifareParams = abtMifareParams;
|
||||||
|
|
||||||
// Historical Bytes
|
// Historical Bytes
|
||||||
pbtHBt = iso14443a_extract_historical_bytes (pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen, &szHBt);
|
pbtHBt = iso14443a_locate_historical_bytes (pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen, &szHBt);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ append_iso14443a_crc (byte_t * pbtData, size_t szLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
byte_t *
|
byte_t *
|
||||||
iso14443a_extract_historical_bytes(byte_t * pbtAts, size_t szAts, size_t * pszHB)
|
iso14443a_locate_historical_bytes(byte_t * pbtAts, size_t szAts, size_t * pszTk)
|
||||||
{
|
{
|
||||||
if (szAts) {
|
if (szAts) {
|
||||||
size_t offset = 1;
|
size_t offset = 1;
|
||||||
|
@ -68,10 +68,10 @@ iso14443a_extract_historical_bytes(byte_t * pbtAts, size_t szAts, size_t * pszHB
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
if (szAts > offset) {
|
if (szAts > offset) {
|
||||||
*pszHB = (szAts-offset);
|
*pszTk = (szAts-offset);
|
||||||
return (pbtAts+offset);
|
return (pbtAts+offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pszHB = 0;
|
*pszTk = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue