Update early data test for an even later arrival of CF
authorMatt Caswell <matt@openssl.org>
Thu, 30 Mar 2017 16:38:15 +0000 (17:38 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 3 Apr 2017 18:07:29 +0000 (19:07 +0100)
Commit 9b5c865df introduced a synthetic delay between arrival of EoED and
CF. We actually want to delay the arrival of CF even further to demonstrate
that we can write early data even when "in init".

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3091)

test/sslapitest.c

index ab1d6ffedc2275113af340ec59a2091af5c2c687..8859ef322299422061b43b8e55a6532e269ce3e4 100644 (file)
@@ -1721,13 +1721,6 @@ static int test_early_data_read_write(int idx)
         goto end;
     }
 
-    /* Push the ClientFinished and the normal data back into the server rbio */
-    if (!BIO_write_ex(rbio, data + eoedlen, rawread - eoedlen, &rawwritten)
-            || rawwritten != rawread - eoedlen) {
-        printf("Failed to write the ClientFinished and data to server rbio\n");
-        goto end;
-    }
-
     /*
      * Server has not finished init yet, so should still be able to write early
      * data.
@@ -1738,6 +1731,13 @@ static int test_early_data_read_write(int idx)
         goto end;
     }
 
+    /* Push the ClientFinished and the normal data back into the server rbio */
+    if (!BIO_write_ex(rbio, data + eoedlen, rawread - eoedlen, &rawwritten)
+            || rawwritten != rawread - eoedlen) {
+        printf("Failed to write the ClientFinished and data to server rbio\n");
+        goto end;
+    }
+
     /* Server should be able to read normal data */
     if (!SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes)
             || readbytes != strlen(MSG5)) {
@@ -1759,16 +1759,6 @@ static int test_early_data_read_write(int idx)
     }
     ERR_clear_error();
 
-    /*
-     * Make sure we process the NewSessionTicket. This arrives post-handshake.
-     * We attempt a read which we do not expect to return any data.  Doesn't
-     * apply when read_ahead is in use - the ticket will get processed along
-     * with the application data in the second read below.
-     */
-    if (idx == 0 && SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)) {
-        printf("Unexpected success doing final client read\n");
-        goto end;
-    }
     /* Client should be able to read the data sent by the server */
     if (!SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)
             || readbytes != strlen(MSG6)
@@ -1776,7 +1766,14 @@ static int test_early_data_read_write(int idx)
         printf("Failed reading message 6\n");
         goto end;
     }
-
+    /*
+     * Make sure we process the NewSessionTicket. This arrives post-handshake.
+     * We attempt a read which we do not expect to return any data.
+     */
+    if (SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)) {
+        printf("Unexpected success doing final client read\n");
+        goto end;
+    }
 
     SSL_SESSION_free(sess);
     sess = SSL_get1_session(clientssl);