If the plaintext is shorter than the block size of the used cipher,
_gnutls_auth_cipher_encrypt2_tag calls _gnutls_cipher_encrypt2 with
textlen = 0. By definition _gnutls_cipher_encrypt2 does nothing in this
case and thus does not need to be called.
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
l = (textlen / blocksize) * blocksize;
- ret =
- _gnutls_cipher_encrypt2(&handle->cipher, text,
+ if (l > 0) {
+ ret =
+ _gnutls_cipher_encrypt2(&handle->cipher, text,
l, ciphertext,
ciphertextlen);
- if (ret < 0)
- return gnutls_assert_val(ret);
+ if (ret < 0)
+ return gnutls_assert_val(ret);
- textlen -= l;
- text += l;
- ciphertext += l;
- ciphertextlen -= l;
+ textlen -= l;
+ text += l;
+ ciphertext += l;
+ ciphertextlen -= l;
+ }
if (ciphertext != text && textlen > 0)
memcpy(ciphertext, text, textlen);