diff options
Diffstat (limited to 'tests/tls13/no-psk-exts.c')
-rw-r--r-- | tests/tls13/no-psk-exts.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/tests/tls13/no-psk-exts.c b/tests/tls13/no-psk-exts.c index f5390e803c..55b9ccccd0 100644 --- a/tests/tls13/no-psk-exts.c +++ b/tests/tls13/no-psk-exts.c @@ -20,7 +20,7 @@ */ #ifdef HAVE_CONFIG_H -#include <config.h> +# include <config.h> #endif #include <stdio.h> @@ -35,20 +35,20 @@ int main(void) #else -#include <string.h> -#include <sys/types.h> -#include <netinet/in.h> -#include <sys/socket.h> -#include <sys/wait.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <gnutls/gnutls.h> -#include <gnutls/dtls.h> -#include <signal.h> - -#include "cert-common.h" -#include "tls13/ext-parse.h" -#include "utils.h" +# include <string.h> +# include <sys/types.h> +# include <netinet/in.h> +# include <sys/socket.h> +# include <sys/wait.h> +# include <arpa/inet.h> +# include <unistd.h> +# include <gnutls/gnutls.h> +# include <gnutls/dtls.h> +# include <signal.h> + +# include "cert-common.h" +# include "tls13/ext-parse.h" +# include "utils.h" /* This program tests whether a connection without the PSK priority * options, will contain PSK extensions */ @@ -63,7 +63,7 @@ static void client_log_func(int level, const char *str) fprintf(stderr, "client|<%d>| %s", level, str); } -#define MAX_BUF 1024 +# define MAX_BUF 1024 static void client(int fd) { @@ -84,11 +84,14 @@ static void client(int fd) /* Initialize TLS session */ - gnutls_init(&session, GNUTLS_CLIENT|GNUTLS_NO_TICKETS); + gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_NO_TICKETS); gnutls_handshake_set_timeout(session, get_timeout()); - ret = gnutls_priority_set_direct(session, "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:+VERS-TLS1.0", NULL); + ret = + gnutls_priority_set_direct(session, + "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:+VERS-TLS1.0", + NULL); if (ret < 0) fail("cannot set TLS 1.3 priorities\n"); @@ -109,7 +112,8 @@ static void client(int fd) /* try if gnutls_reauth() would fail as expected */ ret = gnutls_reauth(session, 0); if (ret != GNUTLS_E_INVALID_REQUEST) - fail("server: gnutls_reauth did not fail as expected: %s", gnutls_strerror(ret)); + fail("server: gnutls_reauth did not fail as expected: %s", + gnutls_strerror(ret)); close(fd); @@ -123,11 +127,12 @@ static void client(int fd) static unsigned server_hello_ok = 0; -#define TLS_EXT_PSK 41 -#define TLS_EXT_PSK_KE 45 +# define TLS_EXT_PSK 41 +# define TLS_EXT_PSK_KE 45 static int hellos_callback(gnutls_session_t session, unsigned int htype, - unsigned post, unsigned int incoming, const gnutls_datum_t *msg) + unsigned post, unsigned int incoming, + const gnutls_datum_t * msg) { if (htype == GNUTLS_HANDSHAKE_SERVER_HELLO && post == GNUTLS_HOOK_POST) { if (find_server_extension(msg, TLS_EXT_PSK_KE, NULL, NULL)) { @@ -172,15 +177,13 @@ static void server(int fd) gnutls_certificate_allocate_credentials(&x509_cred); gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert, - &server_key, - GNUTLS_X509_FMT_PEM); + &server_key, GNUTLS_X509_FMT_PEM); gnutls_init(&session, GNUTLS_SERVER); gnutls_handshake_set_timeout(session, get_timeout()); gnutls_handshake_set_hook_function(session, GNUTLS_HANDSHAKE_ANY, - GNUTLS_HOOK_BOTH, - hellos_callback); + GNUTLS_HOOK_BOTH, hellos_callback); /* avoid calling all the priority functions, since the defaults * are adequate. @@ -193,12 +196,11 @@ static void server(int fd) do { ret = gnutls_handshake(session); - if (ret == GNUTLS_E_INTERRUPTED) { /* expected */ + if (ret == GNUTLS_E_INTERRUPTED) { /* expected */ break; } } while (ret < 0 && gnutls_error_is_fatal(ret) == 0); - if (server_hello_ok == 0) { fail("server: did not verify the server hello contents\n"); } |