adamreeve commented on code in PR #7459: URL: https://github.com/apache/arrow-rs/pull/7459#discussion_r2070964151
########## parquet/src/file/metadata/reader.rs: ########## @@ -963,15 +962,24 @@ impl ParquetMetaDataReader { let schema_descr = Arc::new(SchemaDescriptor::new(schema)); if let (Some(algo), Some(file_decryption_properties)) = ( - t_file_metadata.encryption_algorithm, + t_file_metadata.encryption_algorithm.clone(), file_decryption_properties, ) { // File has a plaintext footer but encryption algorithm is set file_decryptor = Some(get_file_decryptor( algo, - t_file_metadata.footer_signing_key_metadata.as_deref(), + t_file_metadata + .footer_signing_key_metadata + .clone() Review Comment: Clone is unnecessary ########## parquet/src/file/metadata/reader.rs: ########## @@ -963,15 +962,24 @@ impl ParquetMetaDataReader { let schema_descr = Arc::new(SchemaDescriptor::new(schema)); if let (Some(algo), Some(file_decryption_properties)) = ( - t_file_metadata.encryption_algorithm, + t_file_metadata.encryption_algorithm.clone(), file_decryption_properties, ) { // File has a plaintext footer but encryption algorithm is set file_decryptor = Some(get_file_decryptor( algo, - t_file_metadata.footer_signing_key_metadata.as_deref(), + t_file_metadata + .footer_signing_key_metadata + .clone() + .as_deref(), file_decryption_properties, )?); + if file_decryption_properties.check_plaintext_footer_integrity() { + file_decryptor + .clone() + .unwrap() Review Comment: To avoid this unwrap, you could change `file_decryptor = Some(get_file_decryptor(` above to something like `let file_decryptor_value = get_file_decryptor(`. Then below this block add `file_decryptor = Some(file_decryptor_value)`. Then there's no need to clone. Although the clone could be replaced with an `as_ref` here too but you'd still need an unwrap. ########## parquet/src/encryption/ciphers.rs: ########## @@ -23,12 +23,18 @@ use ring::rand::{SecureRandom, SystemRandom}; use std::fmt::Debug; const RIGHT_TWELVE: u128 = 0x0000_0000_ffff_ffff_ffff_ffff_ffff_ffff; -const NONCE_LEN: usize = 12; -const TAG_LEN: usize = 16; -const SIZE_LEN: usize = 4; +pub(crate) const NONCE_LEN: usize = 12; +pub(crate) const TAG_LEN: usize = 16; +pub(crate) const SIZE_LEN: usize = 4; pub(crate) trait BlockDecryptor: Debug + Send + Sync { fn decrypt(&self, length_and_ciphertext: &[u8], aad: &[u8]) -> Result<Vec<u8>>; + + fn compute_plaintext_footer_tag( Review Comment: Mentioning the footer at this abstraction level feels wrong, I think this could just be called `compute_plaintext_tag`. And the `plaintext_footer` parameter could be named `plaintext`. ########## parquet/src/file/metadata/reader.rs: ########## @@ -963,15 +962,24 @@ impl ParquetMetaDataReader { let schema_descr = Arc::new(SchemaDescriptor::new(schema)); if let (Some(algo), Some(file_decryption_properties)) = ( - t_file_metadata.encryption_algorithm, + t_file_metadata.encryption_algorithm.clone(), Review Comment: This clone is unnecessary, the compiler knows the `encryption_algorithm` member isn't used again. -- 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