From d9b29c2d06529f92af1160fbd947f1b1bc0e7037 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 6 Apr 2024 22:55:39 +0800 Subject: [PATCH] move the MAC (i.e. tag) above the variable length AAD field. --- tools/src/swap_writer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/src/swap_writer.rs b/tools/src/swap_writer.rs index caa4cf45a..86af52418 100644 --- a/tools/src/swap_writer.rs +++ b/tools/src/swap_writer.rs @@ -38,13 +38,13 @@ impl SwapHeader { // note that the nonce is in big-endian format, as is expected for cryptographic matter data.write(&self.partial_nonce.to_be_bytes())?; + // serialize the MAC data offset + data.write(&(self.mac_offset as u32).to_le_bytes())?; // LE because this is a size field + // serialize the AAD data.write(&(self.aad.len() as u32).to_le_bytes())?; // LE because this is a size field data.write(&self.aad)?; // BE because this is cryptographic matter - // serialize the MAC data offset - data.write(&(self.mac_offset as u32).to_le_bytes())?; // LE because this is a size field - output[..data.position() as usize].copy_from_slice(&data.into_inner()); Ok(output)