Skip to content

feat(encryption): add EncryptingFileIO - #1207

Open
shangxinli wants to merge 2 commits into
apache:mainfrom
shangxinli:pr-enc07-encrypting-file-io
Open

shangxinli wants to merge 2 commits into
apache:mainfrom
shangxinli:pr-enc07-encrypting-file-io

Conversation

@shangxinli

Copy link
Copy Markdown
Contributor

Part of #988 (step 7 of the task breakdown), following #1071.

EncryptingFileIO is the FileIO of an encrypted table: the catalog's FileIO paired with the table's EncryptionManager. It mirrors Java's EncryptingFileIO.

  • Plain calls pass through to the wrapped FileIO unchanged, which covers unencrypted files and Parquet files (encrypted natively by the format).
  • ForFile / ForKeyMetadata return a decrypting view for a file whose key metadata is known (manifests, Avro data files, Puffin files). The view wraps the raw file in an EncryptedInputFile and decrypts it through EncryptionManager::Decrypt.
  • NewEncryptingOutputFile wraps a new output file through EncryptionManager::Encrypt and returns the EncryptedOutputFile, so the caller can record the generated key metadata once writing completes.
  • The Arrow I/O adapter unwraps an EncryptingFileIO for plain reads and writes, so Arrow file systems keep their fast path. Decrypting views are not unwrapped.

Not in this PR: reading a manifest list by snapshot key id. That needs the manifest list key unwrap in the bundle-only EncryptionUtil, so it comes with the manifest list reader.

Tests: unit tests with a recording EncryptionManager in encryption_test, and an AES GCM Stream write/read round trip through StandardEncryptionManager and the Arrow adapter in crypto_test.

🤖 Generated with Claude Code

@zhjwpku

zhjwpku commented Dec 3, 2026

Copy link
Copy Markdown
Member

The failure was because of the merging of -Wall flag, which has been fix on main, feel free to rebase, same for #1208 , sorry for the trouble.

EncryptingFileIO is the FileIO of an encrypted table: the catalog's
FileIO paired with the table's EncryptionManager. Plain calls pass
through unchanged (unencrypted files, and Parquet files, which are
encrypted natively). AES GCM Stream files are handled as follows:

- ForFile(io, key_metadata) / ForKeyMetadata(key_metadata): a decrypting
  view for a file whose key metadata is known (manifests, Avro data
  files, Puffin files). It wraps the raw file in an EncryptedInputFile
  and decrypts it through EncryptionManager::Decrypt.
- NewEncryptingOutputFile(path): wraps a new output file through
  EncryptionManager::Encrypt and returns the EncryptedOutputFile, whose
  key metadata the caller records once writing is complete. This mirrors
  Java's EncryptingFileIO.newEncryptingOutputFile.

The Arrow I/O adapter unwraps an EncryptingFileIO for plain reads and
writes, so Arrow file systems keep their fast path.
@shangxinli
shangxinli force-pushed the pr-enc07-encrypting-file-io branch from 3def6f2 to 88ca2fc Compare December 3, 2026 18:34

This branch has not been deployed

No deployments
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