diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-04-21 15:17:38 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-04-21 15:17:38 +0200 |
commit | 7f8a846e5f2c79dd69215f77a49fab1c3e72aecf (patch) | |
tree | 80f73528f3072a5dba3726c0d4c29361c4fb5147 | |
parent | c0b518efde7edc63eed68a4f94dc02cdaa6013c7 (diff) | |
download | gnutls-7f8a846e5f2c79dd69215f77a49fab1c3e72aecf.tar.gz |
tests: cleanup mini-dtls-rehandshake
-rw-r--r-- | tests/mini-dtls-rehandshake.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/tests/mini-dtls-rehandshake.c b/tests/mini-dtls-rehandshake.c index 4f0a98d73a..2ddb5dbfb4 100644 --- a/tests/mini-dtls-rehandshake.c +++ b/tests/mini-dtls-rehandshake.c @@ -69,8 +69,6 @@ static void client_log_func(int level, const char *str) #define MAX_BUF 1024 #define MSG "Hello TLS" -gnutls_session_t session; - static ssize_t push(gnutls_transport_ptr_t tr, const void *data, size_t len) { @@ -84,6 +82,8 @@ static void client(int fd, int server_init) int ret; char buffer[MAX_BUF + 1]; gnutls_anon_client_credentials_t anoncred; + gnutls_session_t session; + /* Need to enable anonymous KX specifically. */ global_init(); @@ -194,27 +194,8 @@ static void client(int fd, int server_init) /* These are global */ -gnutls_anon_server_credentials_t anoncred; pid_t child; -static gnutls_session_t initialize_tls_session(void) -{ - gnutls_session_t session; - - gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM); - gnutls_dtls_set_mtu(session, 1500); - - /* avoid calling all the priority functions, since the defaults - * are adequate. - */ - gnutls_priority_set_direct(session, - "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", - NULL); - - gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); - - return session; -} static void terminate(void) { @@ -229,6 +210,8 @@ static void server(int fd, int server_init) { int ret; char buffer[MAX_BUF + 1]; + gnutls_anon_server_credentials_t anoncred; + gnutls_session_t session; /* this must be called once in the program */ global_init(); @@ -240,7 +223,17 @@ static void server(int fd, int server_init) gnutls_anon_allocate_server_credentials(&anoncred); - session = initialize_tls_session(); + gnutls_init(&session, GNUTLS_SERVER | GNUTLS_DATAGRAM); + gnutls_dtls_set_mtu(session, 1500); + + /* avoid calling all the priority functions, since the defaults + * are adequate. + */ + gnutls_priority_set_direct(session, + "NONE:+VERS-DTLS1.0:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-ECDH:+CURVE-ALL", + NULL); + + gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_transport_set_int(session, fd); gnutls_transport_set_push_function(session, push); |