summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2023-01-06 11:06:43 +0000
committerDaiki Ueno <ueno@gnu.org>2023-01-06 11:06:43 +0000
commitae89e0e3b8b52c8bd4e8fd4c62d9dfa9d69e96b9 (patch)
tree738f4eba338a6377c4268078eb674a3cd4def394
parentd5bd1f8196b699806a11613f848ed00e0d83b20f (diff)
parentf072221bd041d671ed8786e5dbc88f50ccb6bb61 (diff)
downloadgnutls-ae89e0e3b8b52c8bd4e8fd4c62d9dfa9d69e96b9.tar.gz
Merge branch 'wip/dueno/max-record-send-size' into 'master'
build: remove MAX_RECORD_SEND_SIZE in favor of max_record_send_size Closes #815 See merge request gnutls/gnutls!1684
-rw-r--r--lib/cipher.c3
-rw-r--r--lib/gnutls_int.h7
-rw-r--r--lib/range.c4
-rw-r--r--lib/record.c7
4 files changed, 9 insertions, 12 deletions
diff --git a/lib/cipher.c b/lib/cipher.c
index 28eafbe188..3cbf63841b 100644
--- a/lib/cipher.c
+++ b/lib/cipher.c
@@ -460,7 +460,8 @@ encrypt_packet_tls13(gnutls_session_t session,
_gnutls_write_uint64(params->write.sequence_number, &nonce[iv_size-8]);
memxor(nonce, params->write.iv, iv_size);
- max = MAX_RECORD_SEND_SIZE(session);
+ max = max_record_send_size(session) +
+ MAX_RECORD_SEND_OVERHEAD(session);
/* make TLS 1.3 form of data */
total = plain->size + 1 + pad_size;
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index 19da7fcee8..8ebf6b8e35 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -197,9 +197,6 @@ typedef enum record_send_state_t {
* store more data than allowed.
*/
#define MAX_RECORD_SEND_OVERHEAD(session) (MAX_CIPHER_BLOCK_SIZE/*iv*/+MAX_PAD_SIZE+MAX_HASH_SIZE/*MAC*/)
-#define MAX_RECORD_SEND_SIZE(session) (IS_DTLS(session)? \
- (MIN((size_t)gnutls_dtls_get_mtu(session), (size_t)session->security_parameters.max_record_send_size+MAX_RECORD_SEND_OVERHEAD(session))): \
- ((size_t)session->security_parameters.max_record_send_size+MAX_RECORD_SEND_OVERHEAD(session)))
#define MAX_PAD_SIZE 255
#define EXTRA_COMP_SIZE 2048
@@ -1600,9 +1597,7 @@ inline static int _gnutls_set_current_version(gnutls_session_t s, unsigned v)
/* Returns the maximum amount of the plaintext to be sent, considering
* both user-specified/negotiated maximum values.
*/
-inline static size_t max_record_send_size(gnutls_session_t session,
- record_parameters_st *
- record_params)
+inline static size_t max_record_send_size(gnutls_session_t session)
{
size_t max;
diff --git a/lib/range.c b/lib/range.c
index 041578c48b..2b478da459 100644
--- a/lib/range.c
+++ b/lib/range.c
@@ -66,7 +66,7 @@ _gnutls_range_max_lh_pad(gnutls_session_t session, ssize_t data_length,
return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR);
if (vers->tls13_sem) {
- max_pad = max_record_send_size(session, record_params);
+ max_pad = max_record_send_size(session);
fixed_pad = 2;
} else {
max_pad = MAX_PAD_SIZE;
@@ -182,7 +182,7 @@ gnutls_range_split(gnutls_session_t session,
if (ret < 0)
return gnutls_assert_val(ret);
- max_frag = max_record_send_size(session, record_params);
+ max_frag = max_record_send_size(session);
if (orig_high == orig_low) {
int length = MIN(orig_high, max_frag);
diff --git a/lib/record.c b/lib/record.c
index 53adc83076..e5a630ed0d 100644
--- a/lib/record.c
+++ b/lib/record.c
@@ -494,7 +494,7 @@ _gnutls_send_tlen_int(gnutls_session_t session, content_type_t type,
return GNUTLS_E_INVALID_SESSION;
}
- max_send_size = max_record_send_size(session, record_params);
+ max_send_size = max_record_send_size(session);
if (data_size > max_send_size) {
if (IS_DTLS(session))
@@ -522,7 +522,8 @@ _gnutls_send_tlen_int(gnutls_session_t session, content_type_t type,
/* now proceed to packet encryption
*/
- cipher_size = MAX_RECORD_SEND_SIZE(session);
+ cipher_size = max_record_send_size(session) +
+ MAX_RECORD_SEND_OVERHEAD(session);
bufel = _mbuffer_alloc_align16(cipher_size + CIPHER_SLACK_SIZE,
get_total_headers2(session, record_params));
@@ -2202,7 +2203,7 @@ ssize_t gnutls_record_send_file(gnutls_session_t session, int fd,
}
}
- buf_len = MIN(count, MAX(max_record_send_size(session, NULL), 512));
+ buf_len = MIN(count, MAX(max_record_send_size(session), 512));
buf = gnutls_malloc(buf_len);
if (buf == NULL) {