We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62f93d9 commit 3bf8840Copy full SHA for 3bf8840
crypto/tests/test_chacha20.py
@@ -7,4 +7,20 @@
7
VALID_NONCE = B"\x00" * 12
8
assert len(VALID_NONCE) == 12, "VALID_NONCE must be exactly 12 bytes"
9
10
-secure_rng = random.SystemRandom()
+secure_rng = random.SystemRandom()
11
+
12
+def test_invalid_key_size():
13
+ """Test invalid key sizes."""
14
+ try:
15
+ ChaCha20(b"short_key", VALID_NONCE)
16
+ except ValueError as e:
17
+ assert "Key must be exactly 32 bytes" in str(e)
18
+ else:
19
+ assert False, "ValueError was not raised for short key"
20
21
22
+ ChaCha20(b"A" * 33, VALID_NONCE)
23
24
25
26
+ assert False, "ValueError was not raised for long key"
0 commit comments