Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
138 changes: 135 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion parquet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ half = { version = "2.1", default-features = false, features = ["num-traits"] }
crc32fast = { version = "1.4.2", optional = true, default-features = false }
simdutf8 = { workspace = true , optional = true }
ring = { version = "0.17", default-features = false, features = ["std"], optional = true }
aes-gcm = { version = "0.10.3", default-features = false, features = ["aes"], optional = true }
ctr = { version = "0.9.2", default-features = false, optional = true }

[dev-dependencies]
chrono = { workspace = true }
Expand Down Expand Up @@ -116,7 +118,7 @@ crc = ["dep:crc32fast"]
# Enable SIMD UTF-8 validation
simdutf8 = ["dep:simdutf8"]
# Enable Parquet modular encryption support
encryption = ["dep:ring"]
encryption = ["dep:ring", "dep:aes-gcm", "dep:ctr"]
# Enable flate2's default Rust backend
flate2-rust_backend = ["flate2/rust_backend"]
# Enable flate2's zlib-rs backend
Expand Down
2 changes: 1 addition & 1 deletion parquet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The `parquet` crate provides the following features which may be enabled in your
- `crc` - enables functionality to automatically verify checksums of each page (if present) when decoding
- `experimental` - Experimental APIs which may change, even between minor releases
- `simdutf8` (default) - Use the [`simdutf8`] crate for SIMD-accelerated UTF-8 validation
- `encryption` - support for reading / writing encrypted Parquet files
- `encryption` - read and write AES_GCM_V1 and AES_GCM_CTR_V1 files with 128-, 192-, or 256-bit keys
- `variant_experimental` - ⚠️ Experimental [Parquet Variant] support, which may change, even between minor releases.
- `file_experimental` - ⚠️ Experimental [Parquet FILE] logical type support, which may change, even between minor releases.
- `geospatial` - ⚠️ Experimental geospatial support, which may change, even between minor releases.
Expand Down
9 changes: 8 additions & 1 deletion parquet/src/column/page_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::basic::PageType;
use crate::column::page::CompressedPage;
use crate::encryption::ciphers::BlockEncryptor;
use crate::encryption::ciphers::{BlockEncryptor, CtrBlockEncryptor};
use crate::encryption::encrypt::{FileEncryptor, encrypt_thrift_object};
use crate::encryption::modules::{ModuleType, create_module_aad};
use crate::errors::ParquetError;
Expand All @@ -19,6 +19,7 @@ use std::sync::Arc;
pub(crate) struct PageEncryptor {
file_encryptor: Arc<FileEncryptor>,
block_encryptor: Box<dyn BlockEncryptor>,
ctr: Option<Box<CtrBlockEncryptor>>,
row_group_index: usize,
column_index: usize,
page_index: usize,
Expand All @@ -38,6 +39,9 @@ impl PageEncryptor {
Ok(Some(Self {
file_encryptor: file_encryptor.clone(),
block_encryptor,
ctr: file_encryptor
.column_ctr_encryptor(column_path)?
.map(Box::new),
row_group_index,
column_index,
page_index: 0,
Expand All @@ -53,6 +57,9 @@ impl PageEncryptor {
}

fn encrypt_page(&mut self, page: &CompressedPage) -> Result<Vec<u8>> {
if let Some(ctr) = &mut self.ctr {
return ctr.encrypt(page.data(), &[]);
}
let module_type = if page.compressed_page().is_data_page() {
ModuleType::DataPage
} else {
Expand Down
Loading