diff options
Diffstat (limited to 'tests/rsa-psk-cb.c')
-rw-r--r-- | tests/rsa-psk-cb.c | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/tests/rsa-psk-cb.c b/tests/rsa-psk-cb.c index c743491049..b84b7d415b 100644 --- a/tests/rsa-psk-cb.c +++ b/tests/rsa-psk-cb.c @@ -24,7 +24,7 @@ /* Tests the RSA-PSK ciphersuites under TLS1.2 */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <stdio.h> @@ -40,15 +40,15 @@ int main(int argc, char **argv) #else -# include <string.h> -# include <sys/types.h> -# include <sys/socket.h> -# include <sys/wait.h> -# include <unistd.h> -# include <assert.h> -# include <gnutls/gnutls.h> -# include "cert-common.h" -# include "utils.h" +#include <string.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/wait.h> +#include <unistd.h> +#include <assert.h> +#include <gnutls/gnutls.h> +#include "cert-common.h" +#include "utils.h" /* A very basic TLS client, with PSK authentication. */ @@ -60,9 +60,8 @@ static void tls_log_func(int level, const char *str) fprintf(stderr, "%s|<%d>| %s", side, level, str); } -static -int psk_cli_func(gnutls_session_t session, char **username, - gnutls_datum_t * key) +static int psk_cli_func(gnutls_session_t session, char **username, + gnutls_datum_t *key) { *username = gnutls_malloc(5); assert(*username != NULL); @@ -79,8 +78,8 @@ int psk_cli_func(gnutls_session_t session, char **username, return 0; } -# define MAX_BUF 1024 -# define MSG "Hello TLS" +#define MAX_BUF 1024 +#define MSG "Hello TLS" static void client(int sd) { @@ -108,9 +107,10 @@ static void client(int sd) gnutls_init(&session, GNUTLS_CLIENT); /* Use default priorities */ - assert(gnutls_priority_set_direct - (session, "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+RSA-PSK", - NULL) >= 0); + assert(gnutls_priority_set_direct( + session, + "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+RSA-PSK", + NULL) >= 0); /* put the anonymous credentials to the current session */ @@ -155,7 +155,7 @@ static void client(int sd) gnutls_bye(session, GNUTLS_SHUT_RDWR); - end: +end: close(sd); @@ -170,11 +170,10 @@ static void client(int sd) /* This is a sample TLS 1.0 echo server, for PSK authentication. */ -# define MAX_BUF 1024 +#define MAX_BUF 1024 -static int -psk_server_func(gnutls_session_t session, const char *username, - gnutls_datum_t * key) +static int psk_server_func(gnutls_session_t session, const char *username, + gnutls_datum_t *key) { if (debug) printf("psk: username %s\n", username); @@ -218,18 +217,18 @@ static void server(int sd) psk_server_func); gnutls_psk_set_server_credentials_hint(server_pskcred, "hint"); gnutls_certificate_allocate_credentials(&serverx509cred); - gnutls_certificate_set_x509_key_mem(serverx509cred, - &server_cert, &server_key, - GNUTLS_X509_FMT_PEM); + gnutls_certificate_set_x509_key_mem(serverx509cred, &server_cert, + &server_key, GNUTLS_X509_FMT_PEM); gnutls_init(&session, GNUTLS_SERVER); /* avoid calling all the priority functions, since the defaults * are adequate. */ - assert(gnutls_priority_set_direct - (session, "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+RSA-PSK", - NULL) >= 0); + assert(gnutls_priority_set_direct( + session, + "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+RSA-PSK", + NULL) >= 0); gnutls_credentials_set(session, GNUTLS_CRD_PSK, server_pskcred); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, serverx509cred); @@ -256,11 +255,11 @@ static void server(int sd) if (ret == 0) { if (debug) - success - ("server: Peer has closed the GnuTLS connection\n"); + success("server: Peer has closed the GnuTLS connection\n"); break; } else if (ret < 0) { - fail("server: Received corrupted data(%d). Closing...\n", ret); + fail("server: Received corrupted data(%d). Closing...\n", + ret); break; } else if (ret > 0) { /* echo data back to the client @@ -317,4 +316,4 @@ void doit(void) } } -#endif /* _WIN32 */ +#endif /* _WIN32 */ |