From bbbbe6805268cd70a9fd5e06b8f402a07229546e Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 30 Oct 2025 19:21:44 +0000 Subject: [PATCH] Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- chachapoly/chachapoly.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chachapoly/chachapoly.go b/chachapoly/chachapoly.go index dcd3437..3f26db8 100644 --- a/chachapoly/chachapoly.go +++ b/chachapoly/chachapoly.go @@ -28,6 +28,9 @@ func Encrypt(plaintext []byte, key []byte) ([]byte, error) { // Decrypt decrypts data using ChaCha20-Poly1305. func Decrypt(ciphertext []byte, key []byte) ([]byte, error) { + if len(key) != chacha20poly1305.KeySize { + return nil, fmt.Errorf("invalid key size: got %d bytes, want %d bytes", len(key), chacha20poly1305.KeySize) + } aead, err := chacha20poly1305.NewX(key) if err != nil { return nil, err