Use the same encryption growth macro consistently
authorMatt Caswell <matt@openssl.org>
Mon, 7 Nov 2022 12:02:08 +0000 (12:02 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 14 Nov 2022 11:33:47 +0000 (11:33 +0000)
commit3d004cefec5135a3b080dc898d7f7d5452ef309f
tree460746bab7a8777591ad1e6dbd01970ce055e253
parenta05e2aa54887474f7b02387fe7c8902f0ad76179
Use the same encryption growth macro consistently

We had two different macros for calculating the potential growth due to
encryption. The macro we use for allocating the underlying buffer should be
the same one that we use for reserving bytes for encryption growth.

Also if we are adding the MAC independently of the cipher algorithm then
the encryption growth will not include that MAC so we should remove it
from the amount of bytes that we reserve for that growth. Otherwise we
might exceed our buffer size and the WPACKET_reserve operation will
fail.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19264)
ssl/record/rec_layer_s3.c