Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c017804
Allow more encryption algorithms
hsiang-c Jan 6, 2026
1d12eb4
Merge branch 'main' into allow_more_enc_algo
hsiang-c Jan 23, 2026
e8da4b9
Expose new API
hsiang-c Jan 27, 2026
3e1b8a7
Fix API
hsiang-c Jan 27, 2026
1f1f0da
Fix format and clippy
hsiang-c Feb 5, 2026
92b4094
Document new api
hsiang-c Feb 5, 2026
12c1888
Pick algorithm by key size
hsiang-c Feb 14, 2026
3ec6b70
Remove unnecessary tests
hsiang-c Feb 14, 2026
deec81e
Round-trip tests w/ AES-256 encrypted parquet
hsiang-c Feb 19, 2026
35b482f
Merge branch 'main' into allow_more_enc_algo
hsiang-c Feb 19, 2026
f55fe3d
Fix comment
hsiang-c Feb 19, 2026
d92014b
More test cases
hsiang-c Mar 1, 2026
0fa4888
Merge branch 'main' into allow_more_enc_algo
hsiang-c Mar 1, 2026
bd79c92
Align field names
hsiang-c Mar 2, 2026
e95eb4d
Refactor async encryption tests
hsiang-c Mar 4, 2026
e8999d3
Refactor sync encryption tests
hsiang-c Mar 5, 2026
928ec10
Merge branch 'main' into allow_more_enc_algo
hsiang-c Mar 6, 2026
0abe16d
Comment & clean up
hsiang-c Mar 6, 2026
206c6c6
Update comment
hsiang-c Apr 22, 2026
36fd995
Merge branch 'main' into allow_more_enc_algo
hsiang-c Apr 22, 2026
efe04f6
Format
hsiang-c Apr 22, 2026
d26f41b
Revert tests
hsiang-c Apr 30, 2026
1b3f2f7
Revert tests
hsiang-c May 1, 2026
5b8b244
Fix comments
hsiang-c May 1, 2026
96ad92d
Merge branch 'apache:main' into allow_more_enc_algo
hsiang-c May 4, 2026
f414b3e
Extract hardcoded strings to constants
hsiang-c May 4, 2026
4336eed
Clean up
hsiang-c May 4, 2026
44caecc
Revert uncessary changes
hsiang-c May 4, 2026
12d768d
Extract common data
hsiang-c May 4, 2026
06c6b73
Restore one test
hsiang-c May 4, 2026
a91f2f9
Remove the workaround
hsiang-c May 11, 2026
ec912ab
Update test data
hsiang-c May 14, 2026
28f3ab2
Merge branch 'main' into allow_more_enc_algo
hsiang-c May 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions parquet/src/encryption/ciphers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::errors::ParquetError;
use crate::errors::ParquetError::General;
use crate::errors::Result;
use crate::file::metadata::HeapSize;
use ring::aead::{AES_128_GCM, Aad, LessSafeKey, NonceSequence, UnboundKey};
use ring::aead::{AES_128_GCM, AES_256_GCM, Aad, LessSafeKey, NonceSequence, UnboundKey};
use ring::rand::{SecureRandom, SystemRandom};
use std::fmt::Debug;

Expand All @@ -40,10 +40,20 @@ pub(crate) struct RingGcmBlockDecryptor {
}

impl RingGcmBlockDecryptor {
/// Create a new `RingGcmBlockDecryptor` with a given key.
pub(crate) fn new(key_bytes: &[u8]) -> Result<Self> {
// todo support other key sizes
let key = UnboundKey::new(&AES_128_GCM, key_bytes)
.map_err(|_| General("Failed to create AES key".to_string()))?;
let algorithm = if key_bytes.len() == AES_128_GCM.key_len() {
&AES_128_GCM
} else if key_bytes.len() == AES_256_GCM.key_len() {
&AES_256_GCM
} else {
return Err(general_err!(
"Error creating RingGcmBlockDecryptor with unsupported key length: {}",
key_bytes.len()
));
};
let key = UnboundKey::new(algorithm, key_bytes)
.map_err(|_| general_err!("Failed to create {:?} key", algorithm))?;

Ok(Self {
key: LessSafeKey::new(key),
Expand Down Expand Up @@ -144,10 +154,19 @@ impl RingGcmBlockEncryptor {
/// return an error if it wraps around.
pub(crate) fn new(key_bytes: &[u8]) -> Result<Self> {
let rng = SystemRandom::new();

// todo support other key sizes
let key = UnboundKey::new(&AES_128_GCM, key_bytes)
.map_err(|e| general_err!("Error creating AES key: {}", e))?;
let algorithm = if key_bytes.len() == AES_128_GCM.key_len() {
&AES_128_GCM
} else if key_bytes.len() == AES_256_GCM.key_len() {
&AES_256_GCM
} else {
return Err(general_err!(
"Error creating RingGcmBlockEncryptor with unsupported key length: {}",
key_bytes.len()
));
};

let key = UnboundKey::new(algorithm, key_bytes)
.map_err(|e| general_err!("Error creating {:?} key: {}", algorithm, e))?;
let nonce = CounterNonce::new(&rng)?;

Ok(Self {
Expand Down
Loading
Loading