Skip to content

Commit

Permalink
fix: make sure that chacha20poly1305::tests::decrypt_should_fail is n…
Browse files Browse the repository at this point in the history
…ot flaky (#5031)

Signed-off-by: ⭐️NINIKA⭐️ <[email protected]>
  • Loading branch information
DCNick3 authored Sep 4, 2024
1 parent 36bbf04 commit a348b85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crypto/src/encryption/chacha20poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit a348b85

Please sign in to comment.