How NTAG 424 DNA SDM byte offsets are calculated
When Secure Dynamic Messaging (SDM) is enabled on NTAG 424 DNA’s NDEF file (E104h), the chip does not parse URL syntax. Instead, you write an ordinary NDEF URI record containing fixed-length ASCII zero placeholders (0x30), and give ChangeFileSettings (0x5F) the exact byte offsets from byte 0 of E104h where the chip should overwrite dynamic hex on each read.
Three framing details shift those offsets relative to the visible URL string:
- Bytes 0–1 (
NLEN): NFC Forum Type 4 Tags store a 2-byte big-endian message length before the NDEF message (NXP AN12196 §5.7). - Bytes 2–5 (NDEF short-record header): Because
E104his 256 bytes, any single URI record fits within the 1-byte Short Record payload length (≤ 254bytes):D1 01 <payloadLen> 55. - Byte 6 (URI prefix identifier): NFC Forum URI records compress
https://(8 characters) into single byte04h, andhttps://www.(12 characters) into single byte02h. The rest of the UTF-8 URL starts at byte 7 either way.
Here is the build-time byte map for https://verify.example.com/tap?picc_data=00000000000000000000000000000000&cmac=0000000000000000 (94 of 256 bytes):
| Parameter | File offset | 3-byte LE (0x5F) | Length |
|---|---|---|---|
PICCDataOffset | 40 (0x000028) | 28 00 00 | 32 bytes |
SDMMACInputOffset | 40 (0x000028) | 28 00 00 | 38 bytes |
SDMMACOffset | 78 (0x00004E) | 4E 00 00 | 16 bytes |
Choosing SDMMACInputOffset and server verification rules
On each unauthenticated NDEF read, the chip derives a session MAC key from the configured SDMFileRead AES-128 key, UID and 24-bit read counter, then computes an 8-byte truncated AES-CMAC (NIST SP 800-38B; NT4H2421Gx §9.3.7–9.3.9). SDMMACInputOffset tells the chip which ASCII bytes inside E104h (with the dynamic placeholders already filled in) are fed into that CMAC calculation up to SDMMACOffset:
- Start at first mirrored field (default): hashes from
PICCDataOffset(orUIDOffset) through the separator right before the CMAC value (in the example above,38bytes:0000…0000&cmac=). Your verification server must feed the exact same substring into its AES-CMAC check. - Start at URI payload (byte 7): binds the domain name and URL path into the CMAC as well, preventing someone from moving valid query parameters onto another path under the same key.
- Equal to
SDMMACOffset(0 bytes): hashes only the session vectorSV2, without covering any NDEF file bytes.
Keep two architectural boundaries clear before ordering labels: first, rejecting repeated or out-of-order counters catches reused URLs, not a previously unseen tap URL captured earlier (NT4H2421Gx §9.3); second, if you encrypt the UID inside PICCData, the SDMMetaRead key cannot be UID-diversified (AN12196 §3.4.2).