Skip to content

Commit 87097f5

Browse files
committed
Review feedback
1 parent 53a2ace commit 87097f5

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

parquet/src/encryption/ciphers.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) const SIZE_LEN: usize = 4;
3030
pub(crate) trait BlockDecryptor: Debug + Send + Sync {
3131
fn decrypt(&self, length_and_ciphertext: &[u8], aad: &[u8]) -> Result<Vec<u8>>;
3232

33-
fn compute_plaintext_tag(&self, aad: &[u8], plaintext: &mut [u8]) -> Result<Vec<u8>>;
33+
fn compute_plaintext_tag(&self, aad: &[u8], plaintext: &[u8]) -> Result<Vec<u8>>;
3434
}
3535

3636
#[derive(Debug, Clone)]
@@ -66,7 +66,8 @@ impl BlockDecryptor for RingGcmBlockDecryptor {
6666
Ok(result)
6767
}
6868

69-
fn compute_plaintext_tag(&self, aad: &[u8], plaintext: &mut [u8]) -> Result<Vec<u8>> {
69+
fn compute_plaintext_tag(&self, aad: &[u8], plaintext: &[u8]) -> Result<Vec<u8>> {
70+
let mut plaintext = plaintext.to_vec();
7071
let nonce = &plaintext[plaintext.len() - NONCE_LEN - TAG_LEN..plaintext.len() - TAG_LEN];
7172
let nonce = ring::aead::Nonce::try_assume_unique_for_key(nonce)?;
7273
let plaintext_end = plaintext.len() - NONCE_LEN - TAG_LEN;

parquet/src/encryption/decrypt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,10 @@ impl FileDecryptor {
558558
/// Verify the signature of the footer
559559
pub(crate) fn verify_plaintext_footer_signature(
560560
&self,
561-
plaintext_footer: &mut [u8],
561+
plaintext_footer: &[u8],
562562
) -> Result<()> {
563563
// Plaintext footer format is: [plaintext metadata, nonce, authentication tag]
564-
let tag = plaintext_footer[plaintext_footer.len() - TAG_LEN..].to_vec();
564+
let tag = &plaintext_footer[plaintext_footer.len() - TAG_LEN..];
565565
let aad = create_footer_aad(self.file_aad())?;
566566
let footer_decryptor = self.get_footer_decryptor()?;
567567

parquet/src/file/metadata/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ impl ParquetMetaDataReader {
972972
file_decryption_properties,
973973
)?;
974974
if file_decryption_properties.check_plaintext_footer_integrity() && !encrypted_footer {
975-
file_decryptor_value.verify_plaintext_footer_signature(buf.to_vec().as_mut())?;
975+
file_decryptor_value.verify_plaintext_footer_signature(buf)?;
976976
}
977977
file_decryptor = Some(file_decryptor_value);
978978
}

0 commit comments

Comments
 (0)