Skip to content

Commit 9eddec4

Browse files
Handle ChaCha20 encryption and decryption for empty input
1 parent f261f94 commit 9eddec4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crypto/ChaCha20.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def _apply_keystream(self, data: bytes) -> bytes:
8888
bytes: The result of XORing the input data with the ChaCha20 keystream
8989
(ciphertext if plaintext was provided, plaintext if ciphertext was provided).
9090
"""
91+
if len(data) == 0:
92+
return b""
9193
result = b""
9294
chunk_size = 64
9395
start = 0

0 commit comments

Comments
 (0)