]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: client-fast-open: updated for TLS1.3
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 13 Mar 2018 12:47:46 +0000 (13:47 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Mon, 19 Mar 2018 16:19:18 +0000 (17:19 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
tests/client-fastopen.c

index 61df827bff5ca96f537f3ca05d1d8a140b183fe9..0f8026ab085b953ab38449ff2f24fa80b731d832 100644 (file)
@@ -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 */