From 01574b9c01024ad6a0e83cf06412a3816d360469 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 10 May 2018 13:38:32 +0200 Subject: tests: mini-record-timing: updated to work under newer gnutls [ci skip] Signed-off-by: Nikos Mavrogiannopoulos --- tests/suite/mini-record-timing.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/suite/mini-record-timing.c b/tests/suite/mini-record-timing.c index 215c0933d5..712386178d 100644 --- a/tests/suite/mini-record-timing.c +++ b/tests/suite/mini-record-timing.c @@ -45,6 +45,7 @@ int main() #include #include #include +#include #include #include "../utils.h" @@ -102,10 +103,6 @@ const gnutls_datum_t server_key = { server_key_pem, }; -/* A very basic TLS client, with anonymous authentication. - */ - - #define MAX_PER_POINT (684*1024) #define MAX_MEASUREMENTS(np) (MAX_PER_POINT*(np)) #define MAX_BUF 1024 @@ -314,8 +311,7 @@ client(int fd, const char *prio, unsigned int text_size, while (ret < 0 && gnutls_error_is_fatal(ret) == 0); if (ret < 0) { - fprintf(stderr, "client: Handshake failed\n"); - gnutls_perror(ret); + fprintf(stderr, "client: Handshake failed: %s\n", gnutls_strerror(ret)); exit(1); } @@ -470,20 +466,19 @@ static void server(int fd, const char *prio) gnutls_global_set_log_function(server_log_func); gnutls_global_set_log_level(6); #endif - - gnutls_certificate_allocate_credentials(&x509_cred); + assert(gnutls_certificate_allocate_credentials(&x509_cred)>=0); ret = gnutls_certificate_set_x509_key_mem(x509_cred, &server_cert, &server_key, GNUTLS_X509_FMT_PEM); if (ret < 0) { - fprintf(stderr, "Could not set certificate\n"); + fprintf(stderr, "Could not set certificate: %s\n", gnutls_strerror(ret)); return; } #ifdef REHANDSHAKE restart: #endif - gnutls_init(&session, GNUTLS_SERVER); + assert(gnutls_init(&session, GNUTLS_SERVER)>=0); /* avoid calling all the priority functions, since the defaults * are adequate. @@ -491,7 +486,7 @@ static void server(int fd, const char *prio) if ((ret = gnutls_priority_set_direct(session, prio, &err)) < 0) { fprintf(stderr, "Error in priority string %s: %s\n", gnutls_strerror(ret), err); - return; + exit(1); } gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); @@ -512,6 +507,7 @@ static void server(int fd, const char *prio) fprintf(stderr, "server: Handshake has failed (%s)\n\n", gnutls_strerror(ret)); + exit(1); } goto finish; } @@ -546,7 +542,6 @@ static void server(int fd, const char *prio) } else if (ret < 0) fprintf(stderr, "err: %s\n", gnutls_strerror(ret)); - /* do not wait for the peer to close the connection. */ gnutls_bye(session, GNUTLS_SHUT_WR); @@ -741,7 +736,7 @@ int main(int argc, char **argv) remove(test->file); snprintf(prio, sizeof(prio), - "NONE:+COMP-NULL:+AES-128-CBC:+%s:+RSA:%%COMPAT:+VERS-TLS1.2:+VERS-TLS1.1", + "NONE:+COMP-NULL:+AES-128-CBC:+%s:+RSA:%%COMPAT:+VERS-TLS1.2:+VERS-TLS1.1:+SIGN-ALL", hash); printf("\nAES-%s (calculating different padding timings)\n", hash); -- cgit v1.2.1