diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-03-13 13:47:46 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-03-19 17:19:18 +0100 |
commit | 1a8a88079ed062c8efc2ec0b8f345e7471e10eba (patch) | |
tree | 726641788026f19c5fe9ba74b965770d36b25bba | |
parent | a1e0f6ca950a4c035960a1f1b6020bbc96165101 (diff) | |
download | gnutls-1a8a88079ed062c8efc2ec0b8f345e7471e10eba.tar.gz |
tests: client-fast-open: updated for TLS1.3
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r-- | tests/client-fastopen.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/tests/client-fastopen.c b/tests/client-fastopen.c index 61df827bff..0f8026ab08 100644 --- a/tests/client-fastopen.c +++ b/tests/client-fastopen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Red Hat, Inc. + * Copyright (C) 2016-2018 Red Hat, Inc. * * Author: Nikos Mavrogiannopoulos * @@ -15,9 +15,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with GnuTLS; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/> + * */ #ifdef HAVE_CONFIG_H @@ -27,6 +27,9 @@ #include <stdio.h> #include <stdlib.h> +/* This tests gnutls_transport_set_fastopen() operation. + */ + #if defined(_WIN32) int main() @@ -48,6 +51,7 @@ int main() #include <gnutls/dtls.h> #include <gnutls/socket.h> #include <errno.h> +#include <assert.h> #include "cert-common.h" #include "utils.h" @@ -65,7 +69,8 @@ static void client_log_func(int level, const char *str) #define MAX_BUF 1024 -static void client(int fd, struct sockaddr *connect_addr, socklen_t connect_addrlen) +static void client(int fd, struct sockaddr *connect_addr, socklen_t connect_addrlen, + const char *prio) { int ret; char buffer[MAX_BUF + 1]; @@ -87,9 +92,7 @@ static void client(int fd, struct sockaddr *connect_addr, socklen_t connect_addr gnutls_handshake_set_timeout(session, 20 * 1000); /* Use default priorities */ - gnutls_priority_set_direct(session, - "NORMAL:-KX-ALL:+ECDHE-RSA", - NULL); + assert(gnutls_priority_set_direct(session, prio, NULL) >= 0); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); @@ -155,7 +158,7 @@ static void terminate(void) exit(1); } -static void server(int fd) +static void server(int fd, const char *prio) { int ret; gnutls_certificate_credentials_t xcred; @@ -185,9 +188,7 @@ static void server(int fd) /* avoid calling all the priority functions, since the defaults * are adequate. */ - gnutls_priority_set_direct(session, - "NORMAL:-KX-ALL:+ECDHE-RSA", - NULL); + assert(gnutls_priority_set_direct(session, prio, NULL) >= 0); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); @@ -249,7 +250,8 @@ static void ch_handler(int sig) return; } -void doit(void) +static +void run(const char *name, const char *prio) { int ret; struct sockaddr_in saddr; @@ -257,6 +259,8 @@ void doit(void) int listener; int fd; + success("running fast open test for %s\n", name); + signal(SIGCHLD, ch_handler); signal(SIGPIPE, SIG_IGN); @@ -297,7 +301,7 @@ void doit(void) if (fd == -1) fail("error in accept: %s\n", strerror(errno)); - server(fd); + server(fd, prio); wait(&status); check_wait_status(status); @@ -305,9 +309,15 @@ void doit(void) fd = socket(AF_INET, SOCK_STREAM, 0); usleep(1000000); - client(fd, (struct sockaddr*)&saddr, addrlen); + client(fd, (struct sockaddr*)&saddr, addrlen, prio); exit(0); } } +void doit(void) +{ + run("tls1.2", "NORMAL:-VERS-ALL:+VERS-TLS1.2:-KX-ALL:+ECDHE-RSA"); + run("tls1.3", "NORMAL:-VERS-ALL:+VERS-TLS1.3"); +} + #endif /* _WIN32 */ |