diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-03-13 15:46:16 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-03-19 17:19:18 +0100 |
commit | 80f182e8c205d3b25fedbc629d71abcd2483739e (patch) | |
tree | 4958e8376546928ee63f8181fcf8a0342b399927 /tests/mini-server-name.c | |
parent | 671826acc0893f05712266a49dac4851c6523bb7 (diff) | |
download | gnutls-80f182e8c205d3b25fedbc629d71abcd2483739e.tar.gz |
tests: updated for TLS1.3 inclusion
This moves the test to use a specific version or test multiple
TLS versions if applicable.
Resolves #413
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'tests/mini-server-name.c')
-rw-r--r-- | tests/mini-server-name.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/mini-server-name.c b/tests/mini-server-name.c index eba6f58110..0da27cc3e1 100644 --- a/tests/mini-server-name.c +++ b/tests/mini-server-name.c @@ -71,7 +71,7 @@ int _gnutls_server_name_set_raw(gnutls_session_t session, gnutls_server_name_type_t type, const void *name, size_t name_length); -static void client(const char *test_name, int fd, unsigned raw, const char *name, unsigned name_len, int server_err) +static void client(const char *test_name, const char *prio, int fd, unsigned raw, const char *name, unsigned name_len, int server_err) { int ret; gnutls_anon_client_credentials_t anoncred; @@ -94,7 +94,7 @@ static void client(const char *test_name, int fd, unsigned raw, const char *name gnutls_init(&session, GNUTLS_CLIENT); /* Use default priorities */ - gnutls_priority_set_direct(session, "NORMAL", NULL); + gnutls_priority_set_direct(session, prio, NULL); /* put the anonymous credentials to the current session */ @@ -152,7 +152,7 @@ static void terminate(void) exit(1); } -static void server(const char *test_name, int fd, const char *name, unsigned name_len, int exp_err) +static void server(const char *test_name, const char *prio, int fd, const char *name, unsigned name_len, int exp_err) { int ret; char buffer[MAX_BUF + 1]; @@ -184,7 +184,7 @@ static void server(const char *test_name, int fd, const char *name, unsigned nam /* avoid calling all the priority functions, since the defaults * are adequate. */ - gnutls_priority_set_direct(session, "NORMAL", NULL); + gnutls_priority_set_direct(session, prio, NULL); gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); @@ -258,7 +258,7 @@ static void server(const char *test_name, int fd, const char *name, unsigned nam /* name: the name sent by client * server_exp: the name which should be expected by the server to see */ -static void start(const char *test_name, unsigned raw, const char *name, unsigned len, const char *server_exp, unsigned server_exp_len, int server_error) +static void start(const char *test_name, const char *prio, unsigned raw, const char *name, unsigned len, const char *server_exp, unsigned server_exp_len, int server_error) { int fd[2]; int ret; @@ -279,11 +279,11 @@ static void start(const char *test_name, unsigned raw, const char *name, unsigne if (child) { /* parent */ close(fd[1]); - server(test_name, fd[0], server_exp, server_exp_len, server_error); + server(test_name, prio, fd[0], server_exp, server_exp_len, server_error); kill(child, SIGTERM); } else { close(fd[0]); - client(test_name, fd[1], raw, name, len, server_error); + client(test_name, prio, fd[1], raw, name, len, server_error); exit(0); } } @@ -296,17 +296,35 @@ static void ch_handler(int sig) return; } +#define PRIO_TLS12 "NORMAL:-VERS-ALL:+VERS-TLS1.2" +#define PRIO_TLS13 "NORMAL:-VERS-ALL:+VERS-TLS1.3" +#define PRIO_NORMAL "NORMAL" + void doit(void) { signal(SIGCHLD, ch_handler); signal(SIGPIPE, SIG_IGN); - start("NULL", 0, NULL, 0, NULL, 0, 0); - start("empty", 0, "", 0, "", 0, 0); - start("test.example.com", 0, "test.example.com", strlen("test.example.com"), "test.example.com", strlen("test.example.com"), 0); - start("longtest.example.com", 0, "longtest.example.com.", strlen("longtest.example.com"), "longtest.example.com.", strlen("longtest.example.com"), 0); + start("tls1.2 NULL", PRIO_TLS12, 0, NULL, 0, NULL, 0, 0); + start("tls1.2 empty", PRIO_TLS12, 0, "", 0, "", 0, 0); + start("tls1.2 test.example.com", PRIO_TLS12, 0, "test.example.com", strlen("test.example.com"), "test.example.com", strlen("test.example.com"), 0); + start("tls1.2 longtest.example.com", PRIO_TLS12, 0, "longtest.example.com.", strlen("longtest.example.com"), "longtest.example.com.", strlen("longtest.example.com"), 0); + /* test embedded NULL */ + start("tls1.2 embedded-NULL", PRIO_TLS12, 1, "invalid\x00.example.com.", sizeof("invalid\x00.example.com")-1, NULL, 0, GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER); + + start("tls1.3 NULL", PRIO_TLS13, 0, NULL, 0, NULL, 0, 0); + start("tls1.3 empty", PRIO_TLS13, 0, "", 0, "", 0, 0); + start("tls1.3 test.example.com", PRIO_TLS13, 0, "test.example.com", strlen("test.example.com"), "test.example.com", strlen("test.example.com"), 0); + start("tls1.3 longtest.example.com", PRIO_TLS13, 0, "longtest.example.com.", strlen("longtest.example.com"), "longtest.example.com.", strlen("longtest.example.com"), 0); + /* test embedded NULL */ + start("tls1.3 embedded-NULL", PRIO_TLS13, 1, "invalid\x00.example.com.", sizeof("invalid\x00.example.com")-1, NULL, 0, GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER); + + start("NULL", PRIO_NORMAL, 0, NULL, 0, NULL, 0, 0); + start("empty", PRIO_NORMAL, 0, "", 0, "", 0, 0); + start("test.example.com", PRIO_NORMAL, 0, "test.example.com", strlen("test.example.com"), "test.example.com", strlen("test.example.com"), 0); + start("longtest.example.com", PRIO_NORMAL, 0, "longtest.example.com.", strlen("longtest.example.com"), "longtest.example.com.", strlen("longtest.example.com"), 0); /* test embedded NULL */ - start("embedded-NULL", 1, "invalid\x00.example.com.", sizeof("invalid\x00.example.com")-1, NULL, 0, GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER); + start("embedded-NULL", PRIO_NORMAL, 1, "invalid\x00.example.com.", sizeof("invalid\x00.example.com")-1, NULL, 0, GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER); } #endif /* _WIN32 */ |