From 2a61042accdc754d10b55e5d28b63d0dc188c8f6 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Sat, 20 Apr 2024 07:34:32 -0700 Subject: [PATCH] Only decrypt known size --- protocol/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs index 08fb4f4..7cefaae 100644 --- a/protocol/src/lib.rs +++ b/protocol/src/lib.rs @@ -190,8 +190,8 @@ impl PacketReader { /// # Arguments /// /// - `ciphertext` - The message from the peer. - /// - `contents` - Mutable buffer to write plaintext. - /// - `aad` - Optional authentication for the peer, currently only used for the first round of messages. + /// - `contents` - Mutable buffer to write plaintext. + /// - `aad` - Optional authentication for the peer, currently only used for the first round of messages. /// /// # Errors /// @@ -207,7 +207,7 @@ impl PacketReader { contents[0..msg.len()].copy_from_slice(msg); self.packet_decoding_cipher.decrypt( auth, - contents, + &mut contents[0..msg.len()], tag.try_into().map_err(|_| Error::MessageLengthTooSmall)?, )?;