Skip to content

feat: add standard encryption key metadata - #991

Merged
wgtmac merged 6 commits into
apache:mainfrom
shangxinli:pr/03-key-metadata
Oct 16, 2026
Merged

wgtmac merged 6 commits into
apache:mainfrom
shangxinli:pr/03-key-metadata

Conversation

@shangxinli

@shangxinli shangxinli commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Part of #988.

Adds StandardKeyMetadata, the per-file key metadata of Iceberg table encryption (data key, AAD prefix, file length), serialized byte-compatible with Java. Tests check it against vectors written by Java.

Comment thread src/iceberg/encryption/standard_key_metadata.h
Comment thread src/iceberg/encryption/standard_key_metadata.cc Outdated
shangxinli and others added 6 commits October 15, 2026 07:18
StandardKeyMetadata is the per-file key metadata of the standard Iceberg
encryption scheme: the data encryption key, the AAD prefix (file ID) and,
for AES GCM streams, the encrypted file length. It is stored in the
key_metadata field of data, delete and manifest files, and (encrypted) in
the table metadata encryption-keys for manifest lists.

The serialized form is Java's: a schema version byte (1) followed by an
Avro binary record. Tests check byte-for-byte compatibility with vectors
written by Java (checked in under test/resources/encryption/vectors,
excluded from the text-fixing pre-commit hooks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round trip the extreme and negative file lengths, distinguish an empty
AAD prefix from an absent one, and reject negative byte lengths,
truncated varints and varints longer than ten bytes (as Java's Avro
decoder does). Also clarify why trailing bytes are ignored.
Embed the two key metadata vectors serialized by Iceberg Java in the
test instead of checking in binary files. The other vectors belong to
later steps; this also drops the pre-commit exclusion that was only
needed for binary files.
Avro encodes a union branch index as an int, and Java's
BinaryDecoder.readIndex delegates to readInt, which caps the varint at
five bytes. ReadLong accepted up to ten, so a six-byte encoding of
branch zero parsed here but is rejected by Java.
@wgtmac
wgtmac merged commit 0bdf7ce into apache:main Oct 16, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants