]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_kx_get: allow calling the function during handshake
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 30 Nov 2016 13:18:51 +0000 (14:18 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 1 Dec 2016 08:39:17 +0000 (09:39 +0100)
Previous this function would return garbage during handshake, because
parameters were not considered established, however there are valid
uses of this function during it. For that reason this function is
modified to return a correct value even during handshake (after
a hello is being exchanged).

lib/state.c

index 496afe4af5c3f5365fc73194e31c2e226f866a09..b765142afa7e83a2233788127f611f00b67883da 100644 (file)
@@ -126,7 +126,12 @@ gnutls_certificate_type_get(gnutls_session_t session)
  **/
 gnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session)
 {
-       return session->security_parameters.kx_algorithm;
+       if (session->internals.handshake_in_progress) {
+               /* This allows early call during handshake */
+               return _gnutls_cipher_suite_get_kx_algo(session->security_parameters.cipher_suite);
+       } else {
+               return session->security_parameters.kx_algorithm;
+       }
 }
 
 /**