diff options
author | Nikos <nmav@crystal.(none)> | 2007-12-16 10:22:00 +0200 |
---|---|---|
committer | Nikos <nmav@crystal.(none)> | 2007-12-16 10:31:17 +0200 |
commit | 4da68f7a0d2b81577a1be10d0fe67290e0c6a031 (patch) | |
tree | d29c87d2e99a7eebcd3742784143af90ab01b317 /lib/gnutls_extensions.c | |
parent | 598709ed8e4198e3f8d74cddc8a5f0de91adab07 (diff) | |
download | gnutls-4da68f7a0d2b81577a1be10d0fe67290e0c6a031.tar.gz |
Changes for post_client_hello_function(). The extensions are now parsed in a
callback friendly way. Extensions are now split to APPLICATION and TLS layer.
The APPLICATION layer extensions are parsed before the callback function is called
and the others afterwards. This allows the callback to change the behavior of the
TLS layer parsers by using the data of the APPLICATION layer extensions.
Currently the only application layer extension is defined to be the server name
indication extension.
Diffstat (limited to 'lib/gnutls_extensions.c')
-rw-r--r-- | lib/gnutls_extensions.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/gnutls_extensions.c b/lib/gnutls_extensions.c index 1b804fd60f..ad1babad6d 100644 --- a/lib/gnutls_extensions.c +++ b/lib/gnutls_extensions.c @@ -39,8 +39,8 @@ #include <gnutls_num.h> /* Key Exchange Section */ -#define GNUTLS_EXTENSION_ENTRY(type, ext_func_recv, ext_func_send) \ - { #type, type, ext_func_recv, ext_func_send } +#define GNUTLS_EXTENSION_ENTRY(type, parse_type, ext_func_recv, ext_func_send) \ + { #type, type, parse_type, ext_func_recv, ext_func_send } #define MAX_EXT_SIZE 10 @@ -48,25 +48,31 @@ const int _gnutls_extensions_size = MAX_EXT_SIZE; gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = { GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_MAX_RECORD_SIZE, + EXTENSION_TLS, _gnutls_max_record_recv_params, _gnutls_max_record_send_params), GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_CERT_TYPE, + EXTENSION_TLS, _gnutls_cert_type_recv_params, _gnutls_cert_type_send_params), GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SERVER_NAME, + EXTENSION_APPLICATION, _gnutls_server_name_recv_params, _gnutls_server_name_send_params), #ifdef ENABLE_OPRFI GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_OPAQUE_PRF_INPUT, + EXTENSION_TLS, _gnutls_oprfi_recv_params, _gnutls_oprfi_send_params), #endif #ifdef ENABLE_SRP GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_SRP, + EXTENSION_TLS, _gnutls_srp_recv_params, _gnutls_srp_send_params), #endif GNUTLS_EXTENSION_ENTRY (GNUTLS_EXTENSION_INNER_APPLICATION, + EXTENSION_TLS, _gnutls_inner_application_recv_params, _gnutls_inner_application_send_params), {0, 0, 0, 0} @@ -83,10 +89,10 @@ gnutls_extension_entry _gnutls_extensions[MAX_EXT_SIZE] = { /* EXTENSION functions */ ext_recv_func -_gnutls_ext_func_recv (uint16_t type) +_gnutls_ext_func_recv (uint16_t type, tls_ext_parse_type_t parse_type) { ext_recv_func ret = NULL; - GNUTLS_EXTENSION_LOOP (ret = p->gnutls_ext_func_recv); + GNUTLS_EXTENSION_LOOP (if (parse_type == EXTENSION_ANY || p->parse_type == parse_type) ret = p->gnutls_ext_func_recv); return ret; } @@ -132,8 +138,8 @@ _gnutls_extension_list_check (gnutls_session_t session, uint16_t type) } int -_gnutls_parse_extensions (gnutls_session_t session, const opaque * data, - int data_size) +_gnutls_parse_extensions (gnutls_session_t session, tls_ext_parse_type_t parse_type, + const opaque * data, int data_size) { int next, ret; int pos = 0; @@ -185,7 +191,7 @@ _gnutls_parse_extensions (gnutls_session_t session, const opaque * data, sdata = &data[pos]; pos += size; - ext_recv = _gnutls_ext_func_recv (type); + ext_recv = _gnutls_ext_func_recv (type, parse_type); if (ext_recv == NULL) continue; if ((ret = ext_recv (session, sdata, size)) < 0) |