From 6bb11e60b7a2dbf735e74cb8b8bf1a7c3e9509a0 Mon Sep 17 00:00:00 2001 From: Samuel Date: Sun, 19 Jan 2025 18:56:43 +0100 Subject: [PATCH] fix: reset position before demanding new data for frame decryption --- src/lib.rs | 4 ++-- test/src/App.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b4614d..cba3b56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -513,8 +513,6 @@ impl BackupDecryptor { Err(e) => return Err(e), }; - // if we got to an attachment, but there we demand more data, it will be faulty, because we try to decrypt the frame although we would need - // to decrypt the attachment match decrypt_frame( &mut self.reader, hmac, @@ -524,6 +522,8 @@ impl BackupDecryptor { frame_length, ) { Ok(None) => { + // here we have to reset as well because the hmac depends on the length decryption which should therefore happen next time on the correct bits + self.reader.set_position(initial_reader_position); return Ok(true); } Ok(Some(backup_frame)) => { diff --git a/test/src/App.tsx b/test/src/App.tsx index 934806f..b86955a 100644 --- a/test/src/App.tsx +++ b/test/src/App.tsx @@ -133,6 +133,7 @@ const App: Component = () => { { setBackupFile(event.currentTarget.files?.[0]); }}