Codebase list openssl / 80eff00
Test that we can process a KeyUpdate received after we sent close_notify Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7114) Kurt Roeckx authored 5 years ago Matt Caswell committed 5 years ago
1 changed file(s) with 27 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
53405340 * Test 1: TLSv1.2, server continues to read/write after client shutdown
53415341 * Test 2: TLSv1.3, no pending NewSessionTicket messages
53425342 * Test 3: TLSv1.3, pending NewSessionTicket messages
5343 * Test 4: TLSv1.3, server continues to read/write after client shutdown, client
5344 * reads it
5343 * Test 4: TLSv1.3, server continues to read/write after client shutdown, server
5344 * sends key update, client reads it
53455345 * Test 5: TLSv1.3, server continues to read/write after client shutdown, client
53465346 * doesn't read it
53475347 */
53535353 char msg[] = "A test message";
53545354 char buf[80];
53555355 size_t written, readbytes;
5356 SSL_SESSION *sess;
53565357
53575358 #ifdef OPENSSL_NO_TLS1_2
53585359 if (tst <= 1)
53755376
53765377 if (tst == 3) {
53775378 if (!TEST_true(create_bare_ssl_connection(serverssl, clientssl,
5378 SSL_ERROR_NONE)))
5379 SSL_ERROR_NONE))
5380 || !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
5381 || !TEST_false(SSL_SESSION_is_resumable(sess)))
53795382 goto end;
53805383 } else if (!TEST_true(create_ssl_connection(serverssl, clientssl,
5381 SSL_ERROR_NONE))) {
5384 SSL_ERROR_NONE))
5385 || !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
5386 || !TEST_true(SSL_SESSION_is_resumable(sess))) {
53825387 goto end;
53835388 }
53845389
53995404 * Even though we're shutdown on receive we should still be
54005405 * able to write.
54015406 */
5402 || !TEST_true(SSL_write(serverssl, msg, sizeof(msg)))
5403 || !TEST_int_eq(SSL_shutdown(serverssl), 1))
5407 || !TEST_true(SSL_write(serverssl, msg, sizeof(msg))))
5408 goto end;
5409 if (tst == 4 &&
5410 (!TEST_true(SSL_key_update(serverssl, SSL_KEY_UPDATE_REQUESTED))
5411 || !TEST_true(SSL_write(serverssl, msg, sizeof(msg)))))
5412 goto end;
5413 if (!TEST_int_eq(SSL_shutdown(serverssl), 1))
54045414 goto end;
54055415 if (tst == 4) {
5406 /* Should still be able to read data from server */
5416 /* Should still be able to read data from server */
54075417 if (!TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf),
5408 &readbytes))
5418 &readbytes))
5419 || !TEST_size_t_eq(readbytes, sizeof(msg))
5420 || !TEST_int_eq(memcmp(msg, buf, readbytes), 0)
5421 || !TEST_true(SSL_read_ex(clientssl, buf, sizeof(buf),
5422 &readbytes))
54095423 || !TEST_size_t_eq(readbytes, sizeof(msg))
54105424 || !TEST_int_eq(memcmp(msg, buf, readbytes), 0))
54115425 goto end;
54295443 */
54305444 || !TEST_false(SSL_write_ex(serverssl, msg, sizeof(msg), &written))
54315445 || !TEST_int_eq(SSL_shutdown(clientssl), 1)
5446 || !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
5447 || !TEST_true(SSL_SESSION_is_resumable(sess))
54325448 || !TEST_int_eq(SSL_shutdown(serverssl), 1))
54335449 goto end;
54345450 } else if (tst == 4) {
54375453 * received by the server which has responded with a close_notify. The
54385454 * client needs to read the close_notify sent by the server.
54395455 */
5440 if (!TEST_int_eq(SSL_shutdown(clientssl), 1))
5456 if (!TEST_int_eq(SSL_shutdown(clientssl), 1)
5457 || !TEST_ptr_ne(sess = SSL_get_session(clientssl), NULL)
5458 || !TEST_true(SSL_SESSION_is_resumable(sess)))
54415459 goto end;
54425460 } else {
54435461 /*