RFC-0013: Authenticated Range Reads¶
Status: Proposed; adds
Protector.open_rangeto the RFC-0004 surface and section 8.5 to the envelope specification. No format change.Owner: API and format leads; security-owner approval required.
Last updated: 2026-11-29
Context¶
Large protected objects are read in parts: a video player seeks, an analytics
engine reads one column chunk of a Parquet file, a backup tool restores one
file from an archive. Object stores serve these as ranged reads. With only
open and open_stream, a reader must fetch and decrypt everything before
the bytes it wants, which turns a 1 MiB read of a 50 GiB object into a 50 GiB
transfer.
The v4 records already allow random access: every non-final record has the same size, and each record’s nonce and additional data bind its index and its final flag (the STREAM construction). What was missing is the processing rule and an API.
Binding decision¶
def open_range(
self,
source: Envelope | bytes | BinaryIO,
*,
offset: int,
length: int,
context: EncryptionContext,
) -> bytes: ...
sourceis an envelope, bytes, or a seekable binary stream (for example a local file, or an object-store file object that issues ranged reads).The record layout is derived from the envelope size (specification 8.5). Only the records covering the range are read and authenticated; each returned byte is authenticated together with its position.
A range that runs past the end returns the bytes up to the end, and the final record is always authenticated in that case, so a truncated envelope cannot pass as a short read.
lengthis bounded byPolicy.max_plaintext_bytes, and the envelope’s implied plaintext size byPolicy.max_stream_bytes.The context, key commitment, and recipient manifest are verified exactly as for
open, and the operation is audited asopen_range.
Security consequences¶
Records outside the range are not read, so
open_rangedoes not prove that the rest of the envelope is intact, and bytes appended after the final record go unnoticed unless the range reaches the end. Callers that need the whole envelope verified useopenoropen_stream; integrity of whatopen_rangereturns is not weakened.A reordered, duplicated, or substituted record fails authentication because its index and final flag are bound into the nonce and additional data.
Every call unwraps the data key. Applications that read many ranges should expect one provider call per range.
Alternatives considered¶
An index of record offsets in the header. Rejected: unnecessary, since records have a fixed stride, and it would grow the header with the object.
Returning a decryptor object that caches the data key across reads. Deferred: it keeps the data key in memory between calls and needs its own lifetime rules.
Test and validation requirements¶
tests/integration/test_open_range.py checks every range against plain
slicing as a Hypothesis property over one-shot and streaming envelopes, in
memory and as streams, and covers tampering inside and outside the range,
authenticated ends, truncation, extension, impossible layouts, streams that
misreport their size or fail to seek, policy limits, context mismatch, and
argument validation.
Supersession rules¶
Changes to the range rules require format-lead and security-owner approval.