diff options
Diffstat (limited to 'lib/ext')
-rw-r--r-- | lib/ext/key_share.c | 12 | ||||
-rw-r--r-- | lib/ext/pre_shared_key.c | 15 |
2 files changed, 17 insertions, 10 deletions
diff --git a/lib/ext/key_share.c b/lib/ext/key_share.c index ab8abf8fe6..a8c4bb5cff 100644 --- a/lib/ext/key_share.c +++ b/lib/ext/key_share.c @@ -664,14 +664,14 @@ key_share_send_params(gnutls_session_t session, { unsigned i; int ret; - unsigned char *lengthp; - unsigned int cur_length; unsigned int generated = 0; const gnutls_group_entry_st *group; const version_entry_st *ver; /* this extension is only being sent on client side */ if (session->security_parameters.entity == GNUTLS_CLIENT) { + unsigned int length_pos; + ver = _gnutls_version_max(session); if (unlikely(ver == NULL || ver->key_shares == 0)) return 0; @@ -679,16 +679,13 @@ key_share_send_params(gnutls_session_t session, if (!have_creds_for_tls13(session)) return 0; - /* write the total length later */ - lengthp = &extdata->data[extdata->length]; + length_pos = extdata->length; ret = _gnutls_buffer_append_prefix(extdata, 16, 0); if (ret < 0) return gnutls_assert_val(ret); - cur_length = extdata->length; - if (session->internals.hsk_flags & HSK_HRR_RECEIVED) { /* we know the group */ group = get_group(session); if (unlikely(group == NULL)) @@ -736,7 +733,8 @@ key_share_send_params(gnutls_session_t session, } /* copy actual length */ - _gnutls_write_uint16(extdata->length - cur_length, lengthp); + _gnutls_write_uint16(extdata->length - length_pos - 2, + &extdata->data[length_pos]); } else { /* server */ ver = get_version(session); diff --git a/lib/ext/pre_shared_key.c b/lib/ext/pre_shared_key.c index 240be21625..c66b40e9fd 100644 --- a/lib/ext/pre_shared_key.c +++ b/lib/ext/pre_shared_key.c @@ -267,7 +267,7 @@ client_send_params(gnutls_session_t session, size_t spos; gnutls_datum_t username = {NULL, 0}; gnutls_datum_t user_key = {NULL, 0}, rkey = {NULL, 0}; - gnutls_datum_t client_hello; + unsigned client_hello_len; unsigned next_idx; const mac_entry_st *prf_res = NULL; const mac_entry_st *prf_psk = NULL; @@ -430,8 +430,7 @@ client_send_params(gnutls_session_t session, assert(extdata->length >= sizeof(mbuffer_st)); assert(ext_offset >= (ssize_t)sizeof(mbuffer_st)); ext_offset -= sizeof(mbuffer_st); - client_hello.data = extdata->data+sizeof(mbuffer_st); - client_hello.size = extdata->length-sizeof(mbuffer_st); + client_hello_len = extdata->length-sizeof(mbuffer_st); next_idx = 0; @@ -442,6 +441,11 @@ client_send_params(gnutls_session_t session, } if (prf_res && rkey.size > 0) { + gnutls_datum_t client_hello; + + client_hello.data = extdata->data+sizeof(mbuffer_st); + client_hello.size = client_hello_len; + ret = compute_psk_binder(session, prf_res, binders_len, binders_pos, ext_offset, &rkey, &client_hello, 1, @@ -476,6 +480,11 @@ client_send_params(gnutls_session_t session, } if (prf_psk && user_key.size > 0 && info) { + gnutls_datum_t client_hello; + + client_hello.data = extdata->data+sizeof(mbuffer_st); + client_hello.size = client_hello_len; + ret = compute_psk_binder(session, prf_psk, binders_len, binders_pos, ext_offset, &user_key, &client_hello, 0, |