Skip to content

zero aead decrypt_into output buffer on tag failure - #15895

Open
jmestwa-coder wants to merge 1 commit into
pyca:mainfrom
jmestwa-coder:aead-decrypt-into-zero
Open

jmestwa-coder wants to merge 1 commit into
pyca:mainfrom
jmestwa-coder:aead-decrypt-into-zero

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

AEAD decrypt_into left unauthenticated plaintext in the caller's buffer when the tag check failed:

  • EvpCipherAead::decrypt_into lets EVP_CipherUpdate write straight into buf and only checks the tag in EVP_CipherFinal
  • after InvalidTag, buf holds the tampered plaintext for AESGCM, ChaCha20Poly1305, AESGCMSIV and AESOCB3 (16+ byte inputs), and the whole forged chunk for the Cobblestone decryptors' update_into
  • now zero buf before raising InvalidTag, matching EVP_AEAD_CTX_open on BoringSSL/AWS-LC and Go's crypto/cipher

The test_decrypt_into_invalid_tag tests now assert the buffer is zeroed; the ChaCha20Poly1305, AESGCM and AESGCMSIV ones fail without the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants