From 778d9679e15ac62523ef7eb282783c8ec9bcc6ab Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Sun, 6 Aug 2023 17:06:24 -0400 Subject: [PATCH] fixed major handshake bug --- src/symmetric_state.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/symmetric_state.rs b/src/symmetric_state.rs index bc4a965..878769c 100644 --- a/src/symmetric_state.rs +++ b/src/symmetric_state.rs @@ -119,14 +119,13 @@ impl SymmetricState { pub fn encrypt_and_hash_in_place(&mut self, iv: [u8; AES_GCM_IV_SIZE], plaintext_start: usize, buffer: &mut Vec) { let tag = App::Aead::encrypt_in_place(&self.k, iv, Some(&self.h), &mut buffer[plaintext_start..]); buffer.extend(&tag); - let mut hash = App::Hash::new(); - hash.update(&buffer[plaintext_start..]); - self.h = hash.finish(); + self.mix_hash(&buffer[plaintext_start..]); } /// Corresponds to Noise `DecryptAndHash`. #[must_use] pub fn decrypt_and_hash_in_place(&mut self, iv: [u8; AES_GCM_IV_SIZE], buffer: &mut [u8], tag: [u8; AES_GCM_TAG_SIZE]) -> bool { let mut hash = App::Hash::new(); + hash.update(&self.h); hash.update(buffer); hash.update(&tag); let ret = App::Aead::decrypt_in_place(&self.k, iv, Some(&self.h), buffer, tag);