]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
corrected record overhead calculations
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 19 May 2013 16:23:49 +0000 (18:23 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 19 May 2013 16:24:30 +0000 (18:24 +0200)
NEWS
lib/gnutls_dtls.c

diff --git a/NEWS b/NEWS
index fd769745426e69023fe3baac361af7ce20865c41..ca8f27f7f154727a98fb60b299d6522955ba2d2d 100644 (file)
--- 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
 
index 2785e7bf4a1cdb87074310b3c3e01b824649dcd9..7dcd3505c6fe3a8788d5e98d8039b85d319e523c 100644 (file)
@@ -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);