Skip to content

Fix double increment of clen in AESGCM case of MBEDTLS 3.0+#3030

Open
robo5ive wants to merge 1 commit intoshadowsocks:masterfrom
robo5ive:patch-1
Open

Fix double increment of clen in AESGCM case of MBEDTLS 3.0+#3030
robo5ive wants to merge 1 commit intoshadowsocks:masterfrom
robo5ive:patch-1

Conversation

@robo5ive
Copy link
Contributor

Copilot AI review requested due to automatic review settings March 15, 2026 10:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes AEAD (AES-GCM) ciphertext length handling across mbedTLS versions by avoiding an extra tag-length increment when using mbedTLS 3.0+ APIs (where the API already accounts for the tag length in clen).

Changes:

  • Increment *clen by tlen only for mbedtls_cipher_auth_encrypt() (mbedTLS < 3.0).
  • Avoid incrementing *clen for mbedtls_cipher_auth_encrypt_ext() (mbedTLS 3.0+), preventing a double-count of the tag length.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#if MBEDTLS_VERSION_NUMBER < 0x03000000
err = mbedtls_cipher_auth_encrypt(cipher_ctx->evp, n, nlen, ad, adlen,
m, mlen, c, clen, c + mlen, tlen);
*clen += tlen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants