adamreeve commented on code in PR #7286: URL: https://github.com/apache/arrow-rs/pull/7286#discussion_r2000144395
########## parquet/src/encryption/decrypt.rs: ########## @@ -136,125 +160,211 @@ impl CryptoContext { } } -/// FileDecryptionProperties hold keys and AAD data required to decrypt a Parquet file. -#[derive(Debug, Clone, PartialEq)] -pub struct FileDecryptionProperties { +#[derive(Clone, PartialEq)] +struct ExplicitDecryptionKeys { footer_key: Vec<u8>, column_keys: HashMap<String, Vec<u8>>, +} + +#[derive(Clone)] +enum DecryptionKeys { + Explicit(ExplicitDecryptionKeys), + ViaRetriever(Arc<dyn KeyRetriever>), +} + +/// FileDecryptionProperties hold keys and AAD data required to decrypt a Parquet file. +#[derive(Clone)] +pub struct FileDecryptionProperties { + keys: DecryptionKeys, pub(crate) aad_prefix: Option<Vec<u8>>, } impl FileDecryptionProperties { - /// Returns a new FileDecryptionProperties builder + /// Returns a new [`FileDecryptionProperties`] builder that will use the provided key to + /// decrypt footer metadata. pub fn builder(footer_key: Vec<u8>) -> DecryptionPropertiesBuilder { DecryptionPropertiesBuilder::new(footer_key) } + + /// Returns a new [`FileDecryptionProperties`] builder that uses a [`KeyRetriever`] + /// to get decryption keys based on key metadata. + pub fn with_key_retriever(key_retriever: Arc<dyn KeyRetriever>) -> DecryptionPropertiesBuilder { + DecryptionPropertiesBuilder::new_with_key_retriever(key_retriever) + } } +impl std::fmt::Debug for FileDecryptionProperties { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "FileDecryptionProperties {{ }}") + } +} + +impl PartialEq for FileDecryptionProperties { + // FileDecryptionProperties needs to implement PartialEq to allow + // ParquetMetaData to implement PartialEq. + // We cannot compare a key retriever, but this isn't derived from the metadata. Review Comment: Yeah that's a lot nicer, good idea thanks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org