summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos <nmav@crystal.(none)>2007-12-09 12:49:55 +0200
committerNikos <nmav@crystal.(none)>2007-12-09 12:49:55 +0200
commit3d5af6621fb49e326be35b99cec8556d8c8315ca (patch)
tree71c578c93bcd665a4ac55d204453cba3fa2574e4
parentfd043564b805a1ee1823bfad28a967a6e49bc0d7 (diff)
downloadgnutls-3d5af6621fb49e326be35b99cec8556d8c8315ca.tar.gz
user_hello_func is call always. Even when resuming a session.
-rw-r--r--lib/gnutls_handshake.c55
-rw-r--r--lib/gnutls_handshake.h1
-rw-r--r--lib/gnutls_v2_compat.c20
3 files changed, 41 insertions, 35 deletions
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index 40e118d359..737f5855fa 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -303,6 +303,29 @@ int ret;
return ret;
}
+int _gnutls_user_hello_func( gnutls_session session, gnutls_protocol_t adv_version)
+{
+int ret;
+
+ if (session->internals.user_hello_func != NULL)
+ {
+ ret = session->internals.user_hello_func( session);
+ if (ret < 0)
+ {
+ gnutls_assert();
+ return ret;
+ }
+ /* Here we need to renegotiate the version since the callee might
+ * have disabled some TLS versions.
+ */
+ ret = _gnutls_negotiate_version( session, adv_version);
+ if (ret < 0) {
+ gnutls_assert();
+ return ret;
+ }
+ }
+ return 0;
+}
/* Read a client hello packet.
* A client hello must be a known version client hello
@@ -335,10 +358,11 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
pos += 2;
neg_version = _gnutls_negotiate_version( session, adv_version);
- if (neg_version < 0) {
- gnutls_assert();
- return ret;
- }
+ if (neg_version < 0)
+ {
+ gnutls_assert();
+ return ret;
+ }
/* Read client random value.
*/
@@ -362,6 +386,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
DECR_LEN (len, session_id_len);
+
ret = _gnutls_server_restore_session (session, &data[pos], session_id_len);
pos += session_id_len;
@@ -369,7 +394,7 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
{ /* resumed! */
resume_copy_required_values (session);
session->internals.resumed = RESUME_TRUE;
- return 0;
+ return _gnutls_user_hello_func( session, adv_version);
}
else
{
@@ -412,23 +437,13 @@ _gnutls_read_client_hello (gnutls_session_t session, opaque * data,
}
}
- if (session->internals.user_hello_func != NULL)
+ ret = _gnutls_user_hello_func( session, adv_version);
+ if (ret < 0)
{
- ret = session->internals.user_hello_func( session);
- if (ret < 0)
- {
- gnutls_assert();
- return ret;
- }
- /* Here we need to renegotiate the version since the callee might
- * have disable some TLS versions.
- */
- ret = _gnutls_negotiate_version( session, adv_version);
- if (ret < 0) {
- gnutls_assert();
- return ret;
- }
+ gnutls_assert();
+ return ret;
}
+
/* select an appropriate cipher suite
*/
diff --git a/lib/gnutls_handshake.h b/lib/gnutls_handshake.h
index 5e539bbecc..5cff279add 100644
--- a/lib/gnutls_handshake.h
+++ b/lib/gnutls_handshake.h
@@ -51,6 +51,7 @@ int _gnutls_server_select_suite (gnutls_session_t session, opaque * data,
int datalen);
int _gnutls_negotiate_version( gnutls_session_t session, gnutls_protocol_t adv_version);
+int _gnutls_user_hello_func( gnutls_session, gnutls_protocol_t adv_version);
#define STATE session->internals.handshake_state
/* This returns true if we have got there
diff --git a/lib/gnutls_v2_compat.c b/lib/gnutls_v2_compat.c
index b065a34d0f..95cbd2ff65 100644
--- a/lib/gnutls_v2_compat.c
+++ b/lib/gnutls_v2_compat.c
@@ -154,21 +154,11 @@ _gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
/* call the user hello callback
*/
- if (session->internals.user_hello_func != NULL)
+ ret = _gnutls_user_hello_func( session, adv_version);
+ if (ret < 0)
{
- ret = session->internals.user_hello_func( session);
- if (ret < 0)
- {
- gnutls_assert();
- return ret;
- }
-
- ret = _gnutls_negotiate_version( session, adv_version);
- if (ret < 0)
- {
- gnutls_assert ();
- return ret;
- }
+ gnutls_assert();
+ return ret;
}
/* find an appropriate cipher suite */
@@ -242,7 +232,7 @@ _gnutls_read_client_hello_v2 (gnutls_session_t session, opaque * data,
ret = _gnutls_server_restore_session (session, session_id, session_id_len);
if (ret == 0)
- { /* resumed! */
+ { /* resumed! */
/* get the new random values */
memcpy (session->internals.resumed_security_parameters.
server_random, session->security_parameters.server_random,