From 620987d82fff0a9d75c2f578b5f2b16d73ab68df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=AD=90=EF=B8=8FNINIKA=E2=AD=90=EF=B8=8F?= Date: Wed, 4 Sep 2024 11:11:11 +0300 Subject: [PATCH] fix: make sure that chacha20poly1305::tests::decrypt_should_fail is not flaky MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ⭐️NINIKA⭐️ --- crypto/src/encryption/chacha20poly1305.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/src/encryption/chacha20poly1305.rs b/crypto/src/encryption/chacha20poly1305.rs index ae2ba203bff..65cc85617e5 100644 --- a/crypto/src/encryption/chacha20poly1305.rs +++ b/crypto/src/encryption/chacha20poly1305.rs @@ -104,10 +104,12 @@ mod tests { let mut ciphertext = res.unwrap(); let aad = b"decrypt should succeed".to_vec(); + // decrypt should fail because if mismatched aad cipher.decrypt_easy(&aad, &ciphertext).unwrap_err(); let aad = b"decrypt should fail".to_vec(); - ciphertext[0] ^= ciphertext[1]; + ciphertext[0] ^= 0x01; + // decrypt should fail because of tampered ciphertext cipher.decrypt_easy(&aad, &ciphertext).unwrap_err(); }