From 2d3cff720b1cd394cffbee8d35cd3ebb8bc2ab79 Mon Sep 17 00:00:00 2001 From: Adam Jon Foster Date: Mon, 23 Sep 2024 14:46:31 +0800 Subject: [PATCH] Update iso14443a.c Added custom RATS option Signed-off-by: Adam Jon Foster --- armsrc/iso14443a.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index a433db828..c7fb280ea 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1086,7 +1086,7 @@ bool prepare_allocated_tag_modulation(tag_response_info_t *response_info, uint8_ } } -bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_response_info_t **responses, +bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_t *iRATs, tag_response_info_t **responses, uint32_t *cuid, uint32_t counters[3], uint8_t tearings[3], uint8_t *pages) { uint8_t sak = 0; // The first response contains the ATQA (note: bytes are transmitted in reverse order). @@ -1248,6 +1248,13 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r return false; } } + + // copy the iRATs if supplied + if ((flags & RATS_IN_DATA) == RATS_IN_DATA) { + memcpy(rRATS ,iRATs, sizeof(iRATs)); + // rats len is dictated by the first char of the string, add 2 crc bytes + rRATS_len = (iRATs[0] + 2); + } // if uid not supplied then get from emulator memory if ((memcmp(data, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 10) == 0) || ((flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)) { @@ -1342,6 +1349,8 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r return false; } + + AddCrc14A(rRATS, rRATS_len - 2); AddCrc14A(rPPS, sizeof(rPPS) - 2);