summaryrefslogtreecommitdiff
path: root/lib/handshake.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2019-02-23 21:02:56 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2019-03-19 17:04:07 +0100
commit755196a8c14e435816b633a62158b4868f784338 (patch)
treeb1582dd9171a0dcafa394bbef0863a485c44e92d /lib/handshake.c
parentb6c6e148b542a3ac3b0c407708fbc86e884d4f82 (diff)
downloadgnutls-755196a8c14e435816b633a62158b4868f784338.tar.gz
Improved estimation of wait in gnutls_session_get_data2tmp-improve-session-resumption
Previously we would wait an arbitrary value of 50ms for the server to send session tickets. This change makes the client wait for the estimated single trip time + 60 ms for the server to calculate the session tickets. This improves the chance to obtain tickets from internet servers during the call of gnutls_session_get_data2(). Resolves: #706 Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'lib/handshake.c')
-rw-r--r--lib/handshake.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/handshake.c b/lib/handshake.c
index da1f87d183..45bf99a6f7 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -2782,7 +2782,7 @@ int gnutls_handshake(gnutls_session_t session)
gnutls_gettime(&session->internals.handshake_start_time);
tmo_ms = session->internals.handshake_timeout_ms;
- end = &session->internals.handshake_endtime;
+ end = &session->internals.handshake_abs_timeout;
start = &session->internals.handshake_start_time;
if (tmo_ms && end->tv_sec == 0 && end->tv_nsec == 0) {
@@ -2835,6 +2835,18 @@ int gnutls_handshake(gnutls_session_t session)
_gnutls_epoch_bump(session);
}
+ /* Give an estimation of the round-trip under TLS1.3, used by gnutls_session_get_data2() */
+ if (!IS_SERVER(session) && vers->tls13_sem) {
+ struct timespec handshake_finish_time;
+ gnutls_gettime(&handshake_finish_time);
+
+ if (!(session->internals.hsk_flags & HSK_HRR_RECEIVED)) {
+ session->internals.ertt = timespec_sub_ms(&handshake_finish_time, &session->internals.handshake_start_time)/2;
+ } else {
+ session->internals.ertt = timespec_sub_ms(&handshake_finish_time, &session->internals.handshake_start_time)/4;
+ }
+ }
+
return 0;
}