From: Nikos Mavrogiannopoulos Date: Fri, 5 Feb 2010 13:52:24 +0000 (+0100) Subject: Corrected calculation of session data for PSK ciphersuites. Solves issue #107256... X-Git-Tag: gnutls_2_9_10~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8728945992cce0019e0d286181d81dcd9d280d0d;p=thirdparty%2Fgnutls.git Corrected calculation of session data for PSK ciphersuites. Solves issue #107256 reported by Wolfgang Glas. --- diff --git a/lib/gnutls_session_pack.c b/lib/gnutls_session_pack.c index 27afbc9829..068f694248 100644 --- a/lib/gnutls_session_pack.c +++ b/lib/gnutls_session_pack.c @@ -754,6 +754,7 @@ error: /* Format: * 1 byte the credentials type * 4 bytes the size of the whole structure + * * 4 bytes the size of the PSK username (x) * x bytes the PSK username * 2 bytes the size of secret key in bits @@ -776,9 +777,10 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session) { username_size = strlen (info->username) + 1; /* include the terminating null */ hint_size = strlen (info->hint) + 1; /* include the terminating null */ - pack_size = username_size + hint_size + - 2 + 4 * 3 + info->dh.prime.size + info->dh.generator.size + - info->dh.public_key.size; + + pack_size = 1 + 4 + 4 + username_size + 4 + hint_size + + + 2 + 4 + info->dh.prime.size + 4 + info->dh.generator.size + + 4 + info->dh.public_key.size; } else pack_size = 0; @@ -806,7 +808,6 @@ pack_psk_auth_info (gnutls_session_t session, gnutls_datum_t * packed_session) _gnutls_write_uint32 (pack_size, &packed_session->data[pos]); pos += 4; - if (pack_size > 0) { _gnutls_write_uint32 (username_size, &packed_session->data[pos]);