summaryrefslogtreecommitdiff
path: root/tests/auto-verify.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2018-03-13 13:41:19 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2018-03-19 17:19:18 +0100
commit26427260d9f900000f005d43e5521ec88379d535 (patch)
treee9de5c973e19e47e6390646c2bde2902b313e52c /tests/auto-verify.c
parent158ce4e8c2398f649fea215ad4e40227baca1136 (diff)
downloadgnutls-26427260d9f900000f005d43e5521ec88379d535.tar.gz
tests: auto-verify: update for TLS1.3
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'tests/auto-verify.c')
-rw-r--r--tests/auto-verify.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/tests/auto-verify.c b/tests/auto-verify.c
index 069ea73919..404a1ea9eb 100644
--- a/tests/auto-verify.c
+++ b/tests/auto-verify.c
@@ -1,7 +1,8 @@
/*
* Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ * Copyright (C) 2017-2018 Red Hat, Inc.
*
- * Author: Simon Josefsson
+ * Author: Nikos Mavrogiannopoulos
*
* This file is part of GnuTLS.
*
@@ -32,6 +33,7 @@
#include <gnutls/x509.h>
#include "utils.h"
#include "eagain-common.h"
+#include <assert.h>
/* This tests gnutls_certificate_set_x509_key() */
@@ -179,7 +181,7 @@ const gnutls_datum_t server_key = { server_key_pem,
};
static
-void test_failure(void)
+void test_failure(const char *name, const char *prio)
{
int exit_code = EXIT_SUCCESS;
int ret;
@@ -198,6 +200,8 @@ void test_failure(void)
gnutls_x509_privkey_t pkey;
unsigned status;
+ success("testing cert verification failure for %s\n", name);
+
to_server_len = 0;
to_client_len = 0;
@@ -233,9 +237,9 @@ void test_failure(void)
gnutls_init(&server, GNUTLS_SERVER);
gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
serverx509cred);
- gnutls_priority_set_direct(server,
- "NORMAL:-CIPHER-ALL:+AES-128-GCM",
- NULL);
+ assert(gnutls_priority_set_direct(server,
+ prio,
+ NULL) >= 0);
gnutls_transport_set_push_function(server, server_push);
gnutls_transport_set_pull_function(server, server_pull);
gnutls_transport_set_ptr(server, server);
@@ -264,7 +268,7 @@ void test_failure(void)
if (ret < 0)
exit(1);
- gnutls_priority_set_direct(client, "NORMAL", NULL);
+ assert(gnutls_priority_set_direct(client, prio, NULL) >= 0);
gnutls_transport_set_push_function(client, client_push);
gnutls_transport_set_pull_function(client, client_pull);
gnutls_transport_set_ptr(client, client);
@@ -304,7 +308,7 @@ void test_failure(void)
}
static
-void test_success1(void)
+void test_success1(const char *name, const char *prio)
{
int exit_code = EXIT_SUCCESS;
int ret;
@@ -323,6 +327,8 @@ void test_success1(void)
gnutls_x509_privkey_t pkey;
unsigned status;
+ success("testing cert verification success1 for %s\n", name);
+
to_server_len = 0;
to_client_len = 0;
@@ -358,9 +364,9 @@ void test_success1(void)
gnutls_init(&server, GNUTLS_SERVER);
gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
serverx509cred);
- gnutls_priority_set_direct(server,
- "NORMAL:-CIPHER-ALL:+AES-128-GCM",
- NULL);
+ assert(gnutls_priority_set_direct(server,
+ prio,
+ NULL) >= 0);
gnutls_transport_set_push_function(server, server_push);
gnutls_transport_set_pull_function(server, server_pull);
gnutls_transport_set_ptr(server, server);
@@ -389,7 +395,7 @@ void test_success1(void)
if (ret < 0)
exit(1);
- gnutls_priority_set_direct(client, "NORMAL", NULL);
+ assert(gnutls_priority_set_direct(client, prio, NULL) >= 0);
gnutls_transport_set_push_function(client, client_push);
gnutls_transport_set_pull_function(client, client_pull);
gnutls_transport_set_ptr(client, client);
@@ -429,7 +435,7 @@ void test_success1(void)
}
static
-void test_success2(void)
+void test_success2(const char *name, const char *prio)
{
int exit_code = EXIT_SUCCESS;
int ret;
@@ -447,6 +453,8 @@ void test_success2(void)
gnutls_x509_privkey_t pkey;
unsigned status;
+ success("testing cert verification success2 for %s\n", name);
+
to_server_len = 0;
to_client_len = 0;
@@ -482,9 +490,9 @@ void test_success2(void)
gnutls_init(&server, GNUTLS_SERVER);
gnutls_credentials_set(server, GNUTLS_CRD_CERTIFICATE,
serverx509cred);
- gnutls_priority_set_direct(server,
- "NORMAL:-CIPHER-ALL:+AES-128-GCM",
- NULL);
+ assert(gnutls_priority_set_direct(server,
+ prio,
+ NULL)>=0);
gnutls_transport_set_push_function(server, server_push);
gnutls_transport_set_pull_function(server, server_pull);
gnutls_transport_set_ptr(server, server);
@@ -513,7 +521,7 @@ void test_success2(void)
if (ret < 0)
exit(1);
- gnutls_priority_set_direct(client, "NORMAL", NULL);
+ assert(gnutls_priority_set_direct(client, prio, NULL)>=0);
gnutls_transport_set_push_function(client, client_push);
gnutls_transport_set_pull_function(client, client_pull);
gnutls_transport_set_ptr(client, client);
@@ -552,9 +560,12 @@ void doit(void)
if (debug)
gnutls_global_set_log_level(2);
- test_failure();
- test_success1();
- test_success2();
+ test_failure("tls1.2", "NORMAL:-VERS-ALL:+VERS-TLS1.2");
+ test_failure("tls1.3", "NORMAL:-VERS-ALL:+VERS-TLS1.3");
+ test_success1("tls1.2", "NORMAL:-VERS-ALL:+VERS-TLS1.2");
+ test_success1("tls1.3", "NORMAL:-VERS-ALL:+VERS-TLS1.3");
+ test_success2("tls1.2", "NORMAL:-VERS-ALL:+VERS-TLS1.2");
+ test_success2("tls1.3", "NORMAL:-VERS-ALL:+VERS-TLS1.3");
gnutls_global_deinit();