* error.
*/
static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
- SSL **serverssl, SSL_SESSION **sess)
+ SSL **serverssl, SSL_SESSION **sess, int idx)
{
if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), sctx,
cctx, cert, privkey)) {
return 0;
}
+ /* When idx == 1 we repeat the tests with read_ahead set */
+ if (idx > 0) {
+ SSL_CTX_set_read_ahead(*cctx, 1);
+ SSL_CTX_set_read_ahead(*sctx, 1);
+ }
+
if (!create_ssl_objects(*sctx, *cctx, serverssl, clientssl, NULL, NULL)) {
printf("Unable to create SSL objects\n");
return 0;
return 1;
}
-static int test_early_data_read_write(void)
+static int test_early_data_read_write(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
unsigned char buf[20];
size_t readbytes, written;
- if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess))
+ if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess, idx))
goto end;
/* Write and read some early data */
return testresult;
}
-static int test_early_data_skip(void)
+static int test_early_data_skip(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
* from a client where the early data is not acceptable.
*/
- if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess))
+ if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess, idx))
goto end;
/*
return testresult;
}
-static int test_early_data_not_sent(void)
+static int test_early_data_not_sent(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
* from a client that doesn't send any.
*/
- if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess))
+ if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess, idx))
goto end;
/* Write some data - should block due to handshake with server */
goto end;
}
- /* Should block due to the NewSessionTicket arrival */
- if (SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)) {
- printf("Unexpected success reading message 2\n");
- goto end;
+ /*
+ * Should block due to the NewSessionTicket arrival unless we're using
+ * read_ahead
+ */
+ if (idx == 0) {
+ if (SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)) {
+ printf("Unexpected success reading message 2\n");
+ goto end;
+ }
}
if (!SSL_read_ex(clientssl, buf, sizeof(buf), &readbytes)
return testresult;
}
-static int test_early_data_not_expected(void)
+static int test_early_data_not_expected(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
* client sending some.
*/
- if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess))
+ if (!setupearly_data_test(&cctx, &sctx, &clientssl, &serverssl, &sess, idx))
goto end;
/* Write some early data */
# ifndef OPENSSL_NO_TLS1_2
-static int test_early_data_tls1_2(void)
+static int test_early_data_tls1_2(int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
goto end;
}
+ /* When idx == 1 we repeat the tests with read_ahead set */
+ if (idx > 0) {
+ SSL_CTX_set_read_ahead(cctx, 1);
+ SSL_CTX_set_read_ahead(sctx, 1);
+ }
+
if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
printf("Unable to create SSL objects\n");
goto end;
ADD_TEST(test_early_cb);
#endif
#ifndef OPENSSL_NO_TLS1_3
- ADD_TEST(test_early_data_read_write);
- ADD_TEST(test_early_data_skip);
- ADD_TEST(test_early_data_not_sent);
- ADD_TEST(test_early_data_not_expected);
+ ADD_ALL_TESTS(test_early_data_read_write, 2);
+ ADD_ALL_TESTS(test_early_data_skip, 2);
+ ADD_ALL_TESTS(test_early_data_not_sent, 2);
+ ADD_ALL_TESTS(test_early_data_not_expected, 2);
# ifndef OPENSSL_NO_TLS1_2
- ADD_TEST(test_early_data_tls1_2);
+ ADD_ALL_TESTS(test_early_data_tls1_2, 2);
# endif
#endif