Add trace anntation support for basic Innovatron commands

This commit is contained in:
kormax committed 2026-06-26 23:31:24 +03:00
1 parent 9d7447ddcd
commit 15ab857ea8
3 files changed
+84 -7

No files matched your search

+80 -3
View File
@@ -28,6 +28,7 @@
#include "ui.h"
#include "crc16.h"
#include "crapto1/crapto1.h"
#include "iso14b.h"
#include "protocols.h"
#include "cmdhficlass.h"
#include "cmdhfcalypso.h"
@@ -1227,8 +1228,76 @@ static bool annotateCalypsoApdu(char *exp, size_t size, const uint8_t *apdu, siz
}
}
static bool annotateIso14443bPrime(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response) {
if (cmdsize < 2) {
return false;
}
const uint8_t command = cmd[1];
if (is_response) {
switch (command) {
case ISO14443B_PRIME_CMD_RR:
if (cmdsize == 2 || cmdsize == 4) {
snprintf(exp, size, "RR");
return true;
}
return false;
case ISO14443B_PRIME_CMD_REPGEN:
if (cmdsize < 7) {
return false;
}
if ((cmd[6] & ISO14443B_PRIME_VERLOG_LONG_REPGEN) && cmdsize >= 8) {
snprintf(exp, size, "REPGEN(DIV=%s, VERLOG=%02X, CONFIG=%02X)",
sprint_hex_inrow(cmd + 2, ISO14B_PRIME_DIV_LEN), cmd[6], cmd[7]);
} else {
snprintf(exp, size, "REPGEN(DIV=%s, VERLOG=%02X)",
sprint_hex_inrow(cmd + 2, ISO14B_PRIME_DIV_LEN), cmd[6]);
}
return true;
default:
return false;
}
}
switch (command) {
case ISO14443B_PRIME_CMD_APGEN:
if (cmdsize < 3 || cmdsize > 6) {
return false;
}
if (cmdsize == 4 || cmdsize == 6) {
snprintf(exp, size, "APGEN(OccuPar=%02X, Config=%02X)", cmd[2], cmd[3]);
} else {
snprintf(exp, size, "APGEN(OccuPar=%02X)", cmd[2]);
}
return true;
case ISO14443B_PRIME_CMD_ATTRIB:
if (cmdsize != 6 && cmdsize != 8) {
return false;
}
snprintf(exp, size, "ATTRIB(DIV=%s)", sprint_hex_inrow(cmd + 2, ISO14B_PRIME_DIV_LEN));
return true;
case ISO14443B_PRIME_CMD_DISC:
if (cmdsize == 2 || cmdsize == 4) {
snprintf(exp, size, "DISC");
return true;
}
return false;
default:
return false;
}
}
void annotateCalypso(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) {
if (cmdsize < 1 || is_response) {
if (cmdsize < 1) {
return;
}
if (annotateIso14443bPrime(exp, size, cmd, cmdsize, is_response)) {
return;
}
if (is_response) {
return;
}
@@ -1237,7 +1306,7 @@ void annotateCalypso(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
}
if (cmd[0] == ISO14443B_REQB || cmd[0] == ISO14443B_ATTRIB || cmd[0] == ISO14443B_HALT) {
annotateIso14443b(exp, size, cmd, cmdsize);
annotateIso14443b(exp, size, cmd, cmdsize, false);
return;
}
@@ -1925,7 +1994,15 @@ void annotateMfPlus(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
0F = Completion
0A 11 22 33 44 55 66 = Authenticate (11 22 33 44 55 66 = data to authenticate)
**/
void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) {
if (annotateIso14443bPrime(exp, size, cmd, cmdsize, is_response)) {
return;
}
if (is_response) {
return;
}
// xerox anti collison loop / slot select for uid bytes...
if (cmdsize == 1) {
+1 -1
View File
@@ -57,7 +57,7 @@ void annotateLegic(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateCalypso(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
const char *mfpGetAnnotationForCode(uint8_t code);
+3 -3
View File
@@ -820,6 +820,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case PROTO_FMCOS20:
annotateIso14443a(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
break;
case ISO_14443B:
annotateIso14443b(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
break;
case PROTO_CALYPSO:
annotateCalypso(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
break;
@@ -860,9 +863,6 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case PROTO_MFPLUS:
annotateMfPlus(explanation, sizeof(explanation), frame, data_len);
break;
case ISO_14443B:
annotateIso14443b(explanation, sizeof(explanation), frame, data_len);
break;
case TOPAZ:
annotateTopaz(explanation, sizeof(explanation), frame, data_len);
break;