diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-10-12 11:29:57 +0200 |
---|---|---|
committer | Daiki Ueno <dueno@redhat.com> | 2018-11-11 07:03:43 +0100 |
commit | cfe71476b634e38102d214b256a4e4760085b322 (patch) | |
tree | 9e8fd4b670e23e8d554af4d3a419822e009b0aac | |
parent | 787aad1b016d82ebc4a1eda53d30de48f2841311 (diff) | |
download | gnutls-cfe71476b634e38102d214b256a4e4760085b322.tar.gz |
handshake: refactor early secret derivation
Signed-off-by: Daiki Ueno <dueno@redhat.com>
-rw-r--r-- | lib/handshake-tls13.c | 8 | ||||
-rw-r--r-- | lib/handshake.c | 16 |
2 files changed, 8 insertions, 16 deletions
diff --git a/lib/handshake-tls13.c b/lib/handshake-tls13.c index 5fed553310..25ec903bb6 100644 --- a/lib/handshake-tls13.c +++ b/lib/handshake-tls13.c @@ -270,6 +270,14 @@ static int generate_and_set_hs_traffic_keys(gnutls_session_t session) if (unlikely(session->key.proto.tls13.temp_secret_size == 0)) return gnutls_assert_val(GNUTLS_E_INTERNAL_ERROR); + ret = _tls13_derive_secret(session, DERIVED_LABEL, sizeof(DERIVED_LABEL)-1, + NULL, 0, session->key.proto.tls13.temp_secret, + session->key.proto.tls13.temp_secret); + if (ret < 0) { + gnutls_assert(); + return ret; + } + if ((session->security_parameters.entity == GNUTLS_CLIENT && (!(session->internals.hsk_flags & HSK_KEY_SHARE_RECEIVED) || (!(session->internals.hsk_flags & HSK_PSK_KE_MODE_DHE_PSK) && diff --git a/lib/handshake.c b/lib/handshake.c index a760e6d465..f0ed91f976 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -1985,14 +1985,6 @@ read_server_hello(gnutls_session_t session, gnutls_assert(); goto cleanup; } - - ret = _tls13_derive_secret(session, DERIVED_LABEL, sizeof(DERIVED_LABEL)-1, - NULL, 0, session->key.proto.tls13.temp_secret, - session->key.proto.tls13.temp_secret); - if (ret < 0) { - gnutls_assert(); - goto cleanup; - } } ret = set_auth_types(session); @@ -2352,14 +2344,6 @@ int _gnutls_send_server_hello(gnutls_session_t session, int again) } if (vers->tls13_sem) { - ret = _tls13_derive_secret(session, DERIVED_LABEL, sizeof(DERIVED_LABEL)-1, - NULL, 0, session->key.proto.tls13.temp_secret, - session->key.proto.tls13.temp_secret); - if (ret < 0) { - gnutls_assert(); - goto fail; - } - /* Under TLS1.3, the session ID is used for different purposes than * the TLS1.0 session ID. Ensure that there is an internally set * value which the server will see on the original and resumed sessions */ |