diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-06-14 15:31:05 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-06-14 16:22:37 +0200 |
commit | df856bdd513bfa12fa50a1fcb5846b0c1a9dc765 (patch) | |
tree | e81105463f07e919162edb38cc70f055234b56c0 /tests/mini-x509-callbacks.c | |
parent | 0ce8ea03b92ff9e60a96ba1fd3b7ac98b936fea7 (diff) | |
download | gnutls-df856bdd513bfa12fa50a1fcb5846b0c1a9dc765.tar.gz |
Added gnutls_handshake_set_hook_function() to allow hooks on arbitrary handshake messages.
Diffstat (limited to 'tests/mini-x509-callbacks.c')
-rw-r--r-- | tests/mini-x509-callbacks.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/mini-x509-callbacks.c b/tests/mini-x509-callbacks.c index 3d7dac23ee..7984f3126d 100644 --- a/tests/mini-x509-callbacks.c +++ b/tests/mini-x509-callbacks.c @@ -52,6 +52,35 @@ static int post_client_hello_callback (gnutls_session_t session) return 0; } +unsigned int msg_order[] = { + GNUTLS_HANDSHAKE_CLIENT_HELLO, + GNUTLS_HANDSHAKE_SERVER_HELLO, + GNUTLS_HANDSHAKE_CERTIFICATE_PKT, + GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE, + GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST, + GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, + GNUTLS_HANDSHAKE_CERTIFICATE_PKT, + GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE, + GNUTLS_HANDSHAKE_FINISHED, + GNUTLS_HANDSHAKE_FINISHED, +}; + +static int handshake_callback (gnutls_session_t session, unsigned int htype, unsigned int post, unsigned int incoming) +{ +static unsigned idx = 0; + + if (post > 0) + { + if (msg_order[idx] != htype) + { + fail("%s: %s, expected %s\n", incoming!=0?"Received":"Sent", gnutls_handshake_description_get_name(htype), gnutls_handshake_description_get_name(msg_order[idx])); + exit(1); + } + idx++; + } + return 0; +} + static int server_callback (gnutls_session_t session) { @@ -137,6 +166,7 @@ void doit(void) gnutls_certificate_set_verify_function (serverx509cred, server_callback); gnutls_certificate_server_set_request (server, GNUTLS_CERT_REQUEST); gnutls_handshake_set_post_client_hello_function (server, post_client_hello_callback); + gnutls_handshake_set_hook_function (server, GNUTLS_HANDSHAKE_ANY, handshake_callback); /* Init client */ gnutls_certificate_allocate_credentials (&clientx509cred); |