Skip to content
File format

The .mlp file format

A .mlp file is a small binary header followed by the AES-256-GCM output. Two header versions exist. mlp reads both and always writes the current one, version 2.

mlp info shows what a header says without needing the key:

$ mlp info notes.mlp
file:            notes.mlp
format version:  2
original ext:    txt
decrypts to:     notes.txt
stored size:     28 bytes
modified:        2026-10-07T12:10:08+02:00
accessed:        2026-10-07T12:10:08+02:00

Version 2 (current, mlp v0.6+)

All multi-byte integers are big-endian.

FieldSizeNotes
Magic4 bytesASCII MLP1
Version1 byte0x02
Flags1 byteSee below.
Extension length1 byte0–255
Extensionthat many bytesUTF-8, without the dot: txt. Empty for files with no extension.
Nonce12 bytesGCM nonce: 4 zero bytes + the 8-byte counter value (or 12 random bytes after a counter fallback).
Modification time12 bytesOnly if flag bit 0 is set. int64 Unix seconds + uint32 nanoseconds.
Access time12 bytesSame, same condition.
Ciphertext + tagrest of fileGCM output of the (possibly compressed) contents; the last 16 bytes are the authentication tag.

Flags

BitNameMeaning
0timestampsThe two timestamp fields follow the nonce.
1zstdThe contents were zstd-compressed before encryption (v0.7+).
2brotliThe contents were brotli-compressed before encryption (v0.8+).

Bits 1 and 2 are never both set; a header that sets both is rejected. Any other bit is rejected too, rather than ignored: a file from a future mlp that uses a new flag fails loudly instead of decrypting to subtly wrong output.

Timestamps are optional because nothing is ever made up: rotating a version 1 file, which never stored them, produces a version 2 file without them, and mlp info prints timestamps: (not stored).

Tamper protection

The header’s exact bytes are passed to GCM as additional authenticated data. Change anything in it (extension, nonce, a timestamp, a compression flag) and decryption fails with an authentication error, the same as if the ciphertext itself had been altered. mlp verify checks this without writing anything.

Version 2 files made by mlp v0.6.0 and v0.7.0 predate this binding: their headers aren’t protected, only their contents. They still decrypt, with a note suggesting you re-encrypt them. See Compatibility.

Version 1 (mlp v0.1–v0.5)

FieldSizeNotes
Magic4 bytesASCII MLP1
Version1 byte0x01
Extension length1 byte
Extensionthat many bytes
Nonce12 bytes
Ciphertext + tagrest of fileNever compressed.

No flags, no timestamps, and the header isn’t bound to the ciphertext, so editing a version 1 file’s stored extension isn’t detected. Its contents are still fully authenticated. mlp rotate upgrades a version 1 file to version 2.

Size overhead

A file grows by its header plus the 16-byte tag: 35 bytes for a version 2 file with no extension and no timestamps, plus the extension’s length, plus 24 for timestamps. That’s 62 bytes for a typical notes.txt, before compression, which usually more than makes up for it: a 2,800-byte text file can easily come out at 90 bytes.

How the decrypted name is chosen

The .mlp suffix is replaced with the stored extension: notes.mlp with extension txt decrypts to notes.txt; with no extension, to notes. When a batch encrypt had to fall back to appending (notes.txt.mlp, because notes.mlp was already taken by another file in the same run), the name already ends in the extension and isn’t doubled.

Last updated on