Skip to content

Commit 69221ec

Browse files
authored
Fix double increment of clen in AESGCM case of MBEDTLS 3.0+
mbedtls_cipher_auth_encrypt_ext will fill clen with tlen. see https://mbed-tls.readthedocs.io/projects/api/en/v2.28.6/api/file/cipher_8h/#cipher_8h_1a64ea7a5500f054d1d60a22369d171eea
1 parent 5c47b80 commit 69221ec

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/aead.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ aead_cipher_encrypt(cipher_ctx_t *cipher_ctx,
180180
#if MBEDTLS_VERSION_NUMBER < 0x03000000
181181
err = mbedtls_cipher_auth_encrypt(cipher_ctx->evp, n, nlen, ad, adlen,
182182
m, mlen, c, clen, c + mlen, tlen);
183+
*clen += tlen;
183184
#else
184185
err = mbedtls_cipher_auth_encrypt_ext(cipher_ctx->evp, n, nlen, ad, adlen,
185186
m, mlen, c, mlen + tlen, clen, tlen);
186187
#endif
187-
*clen += tlen;
188188
break;
189189
case CHACHA20POLY1305IETF:
190190
err = crypto_aead_chacha20poly1305_ietf_encrypt(c, &long_clen, m, mlen,

0 commit comments

Comments
 (0)