feat(encryption) [1/N] Support encryption: Add crypto for AES-GCM#2026
feat(encryption) [1/N] Support encryption: Add crypto for AES-GCM#2026xanderbailey wants to merge 7 commits intoapache:mainfrom
Conversation
44020d9 to
c5299d9
Compare
c5299d9 to
d9e4e2f
Compare
|
This is awesome! I will take a look since I did a lot of the PME support in Comet. Regarding AES-256-GCM support, last I looked Arrow-rs' Parquet reader only supported 128. Is that not the case anymore? |
|
You are correct by the looks of it! https://github.com/apache/arrow-rs/blob/main/parquet/src/encryption/ciphers.rs |
|
@xanderbailey Thank you for the great work on encryption support! Regarding arror-rs, I removed the hardcoded AES-128 constraint w/ apache/arrow-rs#9203, hope that helps a bit. Because we're using PME with AES-256 cc @mbutrovich |
|
This helps a bunch thanks! |
|
@mbutrovich are you still okay to review this? Keen to start getting stuff merged! |
mbutrovich
left a comment
There was a problem hiding this comment.
This foundation looks solid to me. We'll need a committer to approve, but based on previous Parquet Modular Encryption work this is off to a good start. Thank you for driving this work, @xanderbailey!
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub enum EncryptionAlgorithm { | ||
| /// AES-128 in GCM mode | ||
| Aes128Gcm, |
There was a problem hiding this comment.
We're trying to get 256 added to Arrow-rs, this approach should work with that?
There was a problem hiding this comment.
Correct, the crate has both! Designed to be extended once the arrow PR merges
| /// Returns the key length in bytes for this algorithm. | ||
| pub fn key_length(&self) -> usize { | ||
| match self { | ||
| Self::Aes128Gcm => <Aes128Gcm as KeySizeUser>::KeySize::USIZE, |
There was a problem hiding this comment.
Same question about 256 for these following functions.
|
|
||
| /// A secure encryption key that zeroes its memory on drop. | ||
| pub struct SecureKey { | ||
| key: Zeroizing<Vec<u8>>, |
There was a problem hiding this comment.
Tried to follow best practices here
|
Thanks for the review! I'm new to contributing to iceberg, what's the convention for getting a committer to review? |
We need an Iceberg committer, most likely one of the folks working more closely on the Iceberg-rust repo (@Xuanwo and @liurenjie1024). However, with Lunar New Year I think they'll be slow to respond for a little bit. |
Add Core Encryption Primitives for Iceberg Encryption Support.
Part of #2034
Summary
This PR introduces the foundational cryptographic primitives needed for implementing encryption in iceberg-rust, providing AES-GCM encryption operations that match the Java implementation's behavior and data format.
Motivation
Iceberg's Java implementation supports table-level encryption to protect sensitive data at rest. To achieve feature parity and ensure interoperability between Java and Rust implementations, we need to build encryption support from the ground up. This PR provides the core cryptographic operations that will serve as the foundation for the complete encryption feature.
Changes
New Module: encryption
Added a new encryption module with core AES-GCM cryptographic operations:
Key Features
[12-byte nonce][encrypted data][16-byte GCM authentication tag]
- Round-trip encryption/decryption for both AES-128 and AES-256
- AAD validation
- Empty plaintext handling
- Tamper detection
- Format compatibility verification
Dependencies Added
Compatibility
This implementation directly corresponds to Java's https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/encryption/Ciphers.java:
Testing
Future Work
This PR is the first in a series to implement full encryption support. Upcoming PRs will add:
Review Notes
Which issue does this PR close?
What changes are included in this PR?
Are these changes tested?
Yes