File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def test_invalid_nonce_size():
4040 assert "Nonce must be exactly 12 bytes" in str (e )
4141 else :
4242 assert False , "ValueError was not raised for long nonce"
43-
43+
4444def test_invalid_counter_values ():
4545 """Test invalid counter values for ChaCha20."""
4646 for invalid_counter in [- 1 , - 100 , - 999999 ]:
@@ -50,3 +50,12 @@ def test_invalid_counter_values():
5050 assert "Counter must be a non-negative integer" in str (e )
5151 else :
5252 assert False , f"ValueError not raised for counter={ invalid_counter } "
53+
54+ def test_encrypt_decrypt ():
55+ """Test encryption and decryption are symmetric."""
56+ cipher = ChaCha20 (VALID_KEY , VALID_NONCE )
57+ plaintext = b"Hello, ChaCha20!"
58+ ciphertext = cipher .encrypt (plaintext )
59+ decrypted = cipher .decrypt (ciphertext )
60+
61+ assert decrypted == plaintext , "Decryption failed. Plaintext does not match."
You can’t perform that action at this time.
0 commit comments