You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "xanderbailey (via GitHub)" <gi...@apache.org> on 2026/09/16 00:10:33 UTC

Re: [PR] fix(encryption) [18/N] wire in ags1 file length for tamper proofing [iceberg-rust]

xanderbailey commented on code in PR #3236:
URL: https://github.com/apache/iceberg-rust/pull/3236#discussion_r4021342811


##########
crates/iceberg/src/encryption/io.rs:
##########
@@ -74,14 +73,30 @@ impl EncryptedInputFile {
 
     /// Creates a reader that transparently decrypts on each read.
     pub async fn reader(&self) -> Result<Box<dyn FileRead>> {
-        let raw_meta = self.inner.metadata().await?;
+        let encrypted_length = self.encrypted_length()?;
         let raw_reader = self.inner.reader().await?;
         let cipher = build_cipher(&self.key_metadata)?;
         let aad_prefix: Box<[u8]> = self.key_metadata.aad_prefix().unwrap_or_default().into();
-        let decrypting = AesGcmFileRead::new(raw_reader, cipher, aad_prefix, raw_meta.size)?;
+        let decrypting = AesGcmFileRead::new(raw_reader, cipher, aad_prefix, encrypted_length)?;
         Ok(Box::new(decrypting))
     }
 
+    fn encrypted_length(&self) -> Result<u64> {
+        let length = self.key_metadata.file_length().ok_or_else(|| {
+            Error::new(
+                ErrorKind::DataInvalid,
+                "AGS1 key metadata is missing the encrypted file length",

Review Comment:
   https://github.com/apache/iceberg/blob/b3756cd3876bd0ee13383c52ebd05c75df1c3dfe/core/src/main/java/org/apache/iceberg/encryption/AesGcmInputFile.java#L51



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org