From: Nikos Mavrogiannopoulos Date: Sun, 19 May 2013 16:23:49 +0000 (+0200) Subject: corrected record overhead calculations X-Git-Tag: gnutls_3_2_1~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a0130608a651c8a98816be809b346fa8aa40353;p=thirdparty%2Fgnutls.git corrected record overhead calculations --- diff --git a/NEWS b/NEWS index fd76974542..ca8f27f7f1 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ and patch by Tim Kosse. ** libgnutls: Corrected issue when receiving client hello verify requests in DTLS. +** libgnutls: Fixes in DTLS record overhead size calculations. + ** API and ABI modifications: gnutls_session_set_id: Added diff --git a/lib/gnutls_dtls.c b/lib/gnutls_dtls.c index 2785e7bf4a..7dcd3505c6 100644 --- a/lib/gnutls_dtls.c +++ b/lib/gnutls_dtls.c @@ -602,12 +602,11 @@ int total = 0, ret, iv_size; /* requires padding */ iv_size = gnutls_cipher_get_iv_size(params->cipher_algorithm); + total += iv_size; if (_gnutls_cipher_is_block (params->cipher_algorithm) == CIPHER_BLOCK) { - *blocksize = iv_size; - - total += iv_size; /* iv_size == block_size in DTLS */ + *blocksize = iv_size; /* in block ciphers */ /* We always pad with at least one byte; never 0. */ if (session->security_parameters.new_record_padding == 0) @@ -697,8 +696,11 @@ int gnutls_dtls_set_data_mtu (gnutls_session_t session, unsigned int mtu) mtu += overhead; /* Round it up to the next multiple of blocksize */ - mtu += blocksize - 1; - mtu -= mtu % blocksize; + if (blocksize > 1) + { + mtu += blocksize - 1; + mtu -= mtu % blocksize; + } /* Add the *unencrypted header size */ mtu += RECORD_HEADER_SIZE(session);