Record format & recovery

Record formats v2 to v6 · the script opens passphrase slots only

Tagcrypt records are not tied to the app. The format below is complete enough to write your own reader, and the recovery script decrypts a record on any computer with Python 3, offline.

This is a compatibility specification, not a security certification. The app and format have not yet had an independent security audit.

Scope: the byte table below documents v2, the single-secret record. Records that hold several named secrets use v3; v4 to v6 add key slots for optional unlock methods; those are specified in RECORD_FORMAT_V3_V4.md. The recovery script opens v2 and v3 records and the passphrase slots of v4 to v6 records. It cannot use a FIDO2 security key, and it cannot open a record that is protected by a security key alone, which has no passphrase route. Keep the passphrase of any record you may need to recover. Records from early TagVault builds that were tied to one device (v1) are not supported and cannot be recovered.

Downloads

tagcrypt_v2_decrypt.py Offline recovery script (Python 3), reads v2, v3 and the passphrase slots of v4 to v6SHA-256 8f863bae5401adbd11908e8117718afb7d7f323d6b9cc23137377d7349171551
RECORD_FORMAT_V2.md Record format v2 specificationSHA-256 1f9a55b80dcb051ec7a3fd2f5fa2e2f637baea396315c7403fb654939674d68f
RECORD_FORMAT_V3_V4.md Record formats v3 to v6 specificationSHA-256 21203c916e645ce2d9ac6ea9b97d531df826e8e3735fd729c8e1d22f52c7bef3
TEST_VECTORS_V2.md Known-answer test vector (v2)SHA-256 442b11445a6b23608c98af7d59f6c84e2adc94ba24bb84f817dd396cfaa797bf
tests/test_tagcrypt_v2_vectors.py Python tests: v2 known-answer vectorSHA-256 e04b6a7f44b3d15a61e78a1c7bf0a9453a2ccfa3f807cd4e47740a46f399e5c1
tests/test_tagcrypt_v4_recovery.py Python tests: v4 and v5 records, including the v5 fixture (no v6 test yet)SHA-256 53f97804f2a48f840fbce833538a317ba946c068f4e571b6f166fa8a6360a6a8
SHA256SUMS.txt Checksums for the files above

On the tag

One NFC Forum NDEF well-known Text record (TNF 0x01, type T), language en, UTF-8. The text is the Base64 encoding of the binary envelope below. Anyone with an NFC reader can copy it; it is only useful together with the passphrase.

Binary envelope

OffsetLengthField
05ASCII TVLT followed by version byte 0x02 (TVLT is historical: a format constant from before the rename, not a brand name; it must not change)
51KDF id: 0x01 = PBKDF2-HMAC-SHA256
64Iterations, unsigned 32-bit big-endian; exactly 600,000
1016Random salt, new for every record
2612ChaCha20-Poly1305 nonce
38variableCiphertext
end − 1616Poly1305 authentication tag

Key and encryption

Readers must reject unknown magic, version, KDF or iteration values. A failed authentication means a wrong passphrase or a damaged record; no partial plaintext is ever returned.

Checking the downloads and running the tests

Put the files in one folder, keeping the tests and tools subfolders, then run sha256sum -c SHA256SUMS.txt (Linux) or shasum -a 256 -c SHA256SUMS.txt (macOS). With cryptography installed, python3 -m unittest discover -s tests runs the tests. tools/tagcrypt_v2_decrypt.py is a byte-identical copy of the script above so the tests find it.

Passphrases kept in the Recovery Vault or generated by the app live only on that iPhone and are removed when the app is deleted. Export an encrypted backup from the Vault, and keep its backup passphrase separately, before deleting the app or changing phone.

Recovering a record

  1. Use any NFC reader app to copy the Base64 text of the tag's Text record into a file, for example record.txt.
  2. Install the one dependency: python3 -m pip install cryptography
  3. Run python3 tagcrypt_v2_decrypt.py record.txt and type the passphrase when asked. The input is hidden.

The secret is printed to the terminal. Do this on a computer you trust, and clear the terminal afterwards.

Test vector

For checking an implementation only. Never use this passphrase for a real secret.

VFZMVAIBAAknwAABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGht82rRamc5CvvBFf4tU//ntlyjgAUTDoqPFgZ3oNjRpBOqd2T4OZ11kf0ewrn1twSW8hQ5tEp0pCsk5u+fiA6ndUQ==