mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
SSL: Test SSL_get_[rw]poll_descriptor, SSL_net_(read|write)_desired
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21979)
This commit is contained in:
parent
b509d0bd25
commit
7e1b0dc1ef
@ -985,6 +985,7 @@ int create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
|
||||
{
|
||||
SSL *serverssl = NULL, *clientssl = NULL;
|
||||
BIO *s_to_c_bio = NULL, *c_to_s_bio = NULL;
|
||||
BIO_POLL_DESCRIPTOR rdesc = {0}, wdesc = {0};
|
||||
|
||||
if (*sssl != NULL)
|
||||
serverssl = *sssl;
|
||||
@ -999,8 +1000,29 @@ int create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
|
||||
|| !TEST_ptr(c_to_s_bio = BIO_new_socket(cfd, BIO_NOCLOSE)))
|
||||
goto error;
|
||||
|
||||
if (!TEST_false(SSL_get_rpoll_descriptor(clientssl, &rdesc)
|
||||
|| !TEST_false(SSL_get_wpoll_descriptor(clientssl, &wdesc))))
|
||||
goto error;
|
||||
|
||||
SSL_set_bio(clientssl, c_to_s_bio, c_to_s_bio);
|
||||
SSL_set_bio(serverssl, s_to_c_bio, s_to_c_bio);
|
||||
|
||||
if (!TEST_true(SSL_get_rpoll_descriptor(clientssl, &rdesc))
|
||||
|| !TEST_true(SSL_get_wpoll_descriptor(clientssl, &wdesc))
|
||||
|| !TEST_int_eq(rdesc.type, BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD)
|
||||
|| !TEST_int_eq(wdesc.type, BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD)
|
||||
|| !TEST_int_eq(rdesc.value.fd, cfd)
|
||||
|| !TEST_int_eq(wdesc.value.fd, cfd))
|
||||
goto error;
|
||||
|
||||
if (!TEST_true(SSL_get_rpoll_descriptor(serverssl, &rdesc))
|
||||
|| !TEST_true(SSL_get_wpoll_descriptor(serverssl, &wdesc))
|
||||
|| !TEST_int_eq(rdesc.type, BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD)
|
||||
|| !TEST_int_eq(wdesc.type, BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD)
|
||||
|| !TEST_int_eq(rdesc.value.fd, sfd)
|
||||
|| !TEST_int_eq(wdesc.value.fd, sfd))
|
||||
goto error;
|
||||
|
||||
*sssl = serverssl;
|
||||
*cssl = clientssl;
|
||||
return 1;
|
||||
|
@ -6601,7 +6601,9 @@ static int test_key_update_peer_in_write(int tst)
|
||||
|
||||
/* Write data that we know will fail with SSL_ERROR_WANT_WRITE */
|
||||
if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), -1)
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE))
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE)
|
||||
|| !TEST_true(SSL_want_write(peerwrite))
|
||||
|| !TEST_true(SSL_net_write_desired(peerwrite)))
|
||||
goto end;
|
||||
|
||||
/* Reinstate the original writing endpoint's write BIO */
|
||||
@ -6610,7 +6612,9 @@ static int test_key_update_peer_in_write(int tst)
|
||||
|
||||
/* Now read some data - we will read the key update */
|
||||
if (!TEST_int_eq(SSL_read(peerwrite, buf, sizeof(buf)), -1)
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_READ))
|
||||
|| !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_READ)
|
||||
|| !TEST_true(SSL_want_read(peerwrite))
|
||||
|| !TEST_true(SSL_net_read_desired(peerwrite)))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
@ -6626,6 +6630,11 @@ static int test_key_update_peer_in_write(int tst)
|
||||
|| !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess)))
|
||||
goto end;
|
||||
|
||||
if (!TEST_false(SSL_net_read_desired(peerwrite))
|
||||
|| !TEST_false(SSL_net_write_desired(peerwrite))
|
||||
|| !TEST_int_eq(SSL_want(peerwrite), SSL_NOTHING))
|
||||
goto end;
|
||||
|
||||
testresult = 1;
|
||||
|
||||
end:
|
||||
|
Loading…
Reference in New Issue
Block a user