mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-16 17:35:03 +08:00
added ndef tlv parsing
This commit is contained in:
parent
0a30e03aaf
commit
a2f8f0628c
1 changed files with 58 additions and 0 deletions
|
@ -9,8 +9,66 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "ndef.h"
|
#include "ndef.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
uint16_t ndefTLVGetLength(uint8_t *data, size_t *indx) {
|
||||||
|
uint16_t len = 0;
|
||||||
|
if (data[0] == 0xff) {
|
||||||
|
len = (data[1] << 8) + data[2];
|
||||||
|
*indx += 3;
|
||||||
|
} else {
|
||||||
|
len = data[0];
|
||||||
|
*indx += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) {
|
||||||
|
|
||||||
|
size_t indx = 0;
|
||||||
|
|
||||||
|
while (indx < ndefLen) {
|
||||||
|
switch (ndef[indx]) {
|
||||||
|
case 0x00: {
|
||||||
|
indx++;
|
||||||
|
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||||
|
PrintAndLogEx(INFO, "NDEF NULL block.");
|
||||||
|
if (len)
|
||||||
|
PrintAndLogEx(WARNING, "NDEF NULL block size must be 0 instead of %d.", len);
|
||||||
|
indx += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x03: {
|
||||||
|
indx++;
|
||||||
|
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||||
|
PrintAndLogEx(INFO, "NDEF message. len: %d", len);
|
||||||
|
|
||||||
|
// ndef decode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
indx += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0xfd: {
|
||||||
|
indx++;
|
||||||
|
uint16_t len = ndefTLVGetLength(&ndef[indx], &indx);
|
||||||
|
PrintAndLogEx(INFO, "NDEF proprietary info. Skipped %d bytes.", len);
|
||||||
|
indx += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0xfe: {
|
||||||
|
PrintAndLogEx(INFO, "NDEF Terminator. Done.");
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
PrintAndLogEx(ERR, "unknown tag 0x%02x", ndef[indx]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue