提交 0d1b7789 编写于 作者: M Matt Caswell

Add a test for the recv_max_early_data setting

Reviewed-by: NPaul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/6655)
上级 4e8548e8
......@@ -2314,8 +2314,11 @@ static int test_early_data_replay(int idx)
/*
* Helper function to test that a server attempting to read early data can
* handle a connection from a client where the early data should be skipped.
* testtype: 0 == No HRR
* testtype: 1 == HRR
* testtype: 2 == recv_max_early_data set to 0
*/
static int early_data_skip_helper(int hrr, int idx)
static int early_data_skip_helper(int testtype, int idx)
{
SSL_CTX *cctx = NULL, *sctx = NULL;
SSL *clientssl = NULL, *serverssl = NULL;
......@@ -2328,7 +2331,7 @@ static int early_data_skip_helper(int hrr, int idx)
&serverssl, &sess, idx)))
goto end;
if (hrr) {
if (testtype == 1) {
/* Force an HRR to occur */
if (!TEST_true(SSL_set1_groups_list(serverssl, "P-256")))
goto end;
......@@ -2348,13 +2351,17 @@ static int early_data_skip_helper(int hrr, int idx)
goto end;
}
if (testtype == 2
&& !TEST_true(SSL_set_recv_max_early_data(serverssl, 0)))
goto end;
/* Write some early data */
if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
&written))
|| !TEST_size_t_eq(written, strlen(MSG1)))
goto end;
/* Server should reject the early data and skip over it */
/* Server should reject the early data */
if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
&readbytes),
SSL_READ_EARLY_DATA_FINISH)
......@@ -2363,7 +2370,7 @@ static int early_data_skip_helper(int hrr, int idx)
SSL_EARLY_DATA_REJECTED))
goto end;
if (hrr) {
if (testtype == 1) {
/*
* Finish off the handshake. We perform the same writes and reads as
* further down but we expect them to fail due to the incomplete
......@@ -2373,9 +2380,24 @@ static int early_data_skip_helper(int hrr, int idx)
|| !TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf),
&readbytes)))
goto end;
} else if (testtype == 2) {
/*
* This client has sent more early_data than we are willing to skip so
* the connection should abort.
*/
if (!TEST_false(SSL_read_ex(serverssl, buf, sizeof(buf), &readbytes))
|| !TEST_int_eq(SSL_get_error(serverssl, 0), SSL_ERROR_SSL))
goto end;
/* Connection has failed - nothing more to do */
testresult = 1;
goto end;
}
/* Should be able to send normal data despite rejection of early data */
/*
* Should be able to send normal data despite rejection of early data. The
* early_data should be skipped.
*/
if (!TEST_true(SSL_write_ex(clientssl, MSG2, strlen(MSG2), &written))
|| !TEST_size_t_eq(written, strlen(MSG2))
|| !TEST_int_eq(SSL_get_early_data_status(clientssl),
......@@ -2416,6 +2438,15 @@ static int test_early_data_skip_hrr(int idx)
return early_data_skip_helper(1, idx);
}
/*
* Test that a server attempting to read early data will abort if it tries to
* skip over too much.
*/
static int test_early_data_skip_abort(int idx)
{
return early_data_skip_helper(2, idx);
}
/*
* Test that a server attempting to read early data can handle a connection
* from a client that doesn't send any.
......@@ -5267,6 +5298,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_early_data_replay, 2);
ADD_ALL_TESTS(test_early_data_skip, 3);
ADD_ALL_TESTS(test_early_data_skip_hrr, 3);
ADD_ALL_TESTS(test_early_data_skip_abort, 3);
ADD_ALL_TESTS(test_early_data_not_sent, 3);
ADD_ALL_TESTS(test_early_data_psk, 8);
ADD_ALL_TESTS(test_early_data_not_expected, 3);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册