mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-01 22:47:23 +00:00
Move queue management into mbedtls_test_ssl_dtls_join_endpoints
This allows mbedtls_test_ssl_endpoint_init() to no longer interact with the other endpoint. No behavior change. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -205,6 +205,7 @@ typedef struct mbedtls_test_ssl_endpoint {
|
|||||||
|
|
||||||
/* Objects owned by the endpoint */
|
/* Objects owned by the endpoint */
|
||||||
int *ciphersuites;
|
int *ciphersuites;
|
||||||
|
mbedtls_test_ssl_message_queue queue_input;
|
||||||
mbedtls_x509_crt *ca_chain;
|
mbedtls_x509_crt *ca_chain;
|
||||||
mbedtls_x509_crt *cert;
|
mbedtls_x509_crt *cert;
|
||||||
mbedtls_pk_context *pkey;
|
mbedtls_pk_context *pkey;
|
||||||
|
|||||||
@@ -742,16 +742,12 @@ int mbedtls_test_ssl_endpoint_init(
|
|||||||
mbedtls_test_ssl_message_queue *output_queue)
|
mbedtls_test_ssl_message_queue *output_queue)
|
||||||
{
|
{
|
||||||
(void) dtls_context; // no longer used
|
(void) dtls_context; // no longer used
|
||||||
|
(void) input_queue; // no longer used
|
||||||
|
(void) output_queue; // no longer used
|
||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
uintptr_t user_data_n;
|
uintptr_t user_data_n;
|
||||||
|
|
||||||
if (options->dtls &&
|
|
||||||
(input_queue == NULL || output_queue == NULL)) {
|
|
||||||
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ep == NULL) {
|
if (ep == NULL) {
|
||||||
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_SSL_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
@@ -775,13 +771,7 @@ int mbedtls_test_ssl_endpoint_init(
|
|||||||
mbedtls_ssl_conf_set_user_data_n(&ep->conf, user_data_n);
|
mbedtls_ssl_conf_set_user_data_n(&ep->conf, user_data_n);
|
||||||
mbedtls_ssl_set_user_data_n(&ep->ssl, user_data_n);
|
mbedtls_ssl_set_user_data_n(&ep->ssl, user_data_n);
|
||||||
|
|
||||||
if (options->dtls) {
|
mbedtls_test_mock_socket_init(&(ep->socket));
|
||||||
TEST_EQUAL(mbedtls_test_message_socket_setup(input_queue, output_queue,
|
|
||||||
100, &(ep->socket),
|
|
||||||
&ep->dtls_context), 0);
|
|
||||||
} else {
|
|
||||||
mbedtls_test_mock_socket_init(&(ep->socket));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Non-blocking callbacks without timeout */
|
/* Non-blocking callbacks without timeout */
|
||||||
if (options->dtls) {
|
if (options->dtls) {
|
||||||
@@ -938,11 +928,19 @@ int mbedtls_test_ssl_dtls_join_endpoints(mbedtls_test_ssl_endpoint *client,
|
|||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
|
|
||||||
/* Nothing to do yet. */
|
ret = mbedtls_test_message_socket_setup(&client->queue_input,
|
||||||
(void) client;
|
&server->queue_input,
|
||||||
(void) server;
|
100, &(client->socket),
|
||||||
ret = 0;
|
&client->dtls_context);
|
||||||
|
TEST_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
ret = mbedtls_test_message_socket_setup(&server->queue_input,
|
||||||
|
&client->queue_input,
|
||||||
|
100, &(server->socket),
|
||||||
|
&server->dtls_context);
|
||||||
|
TEST_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2142,7 +2140,6 @@ void mbedtls_test_ssl_perform_handshake(
|
|||||||
MD_OR_USE_PSA_INIT();
|
MD_OR_USE_PSA_INIT();
|
||||||
mbedtls_platform_zeroize(&client, sizeof(client));
|
mbedtls_platform_zeroize(&client, sizeof(client));
|
||||||
mbedtls_platform_zeroize(&server, sizeof(server));
|
mbedtls_platform_zeroize(&server, sizeof(server));
|
||||||
mbedtls_test_ssl_message_queue server_queue, client_queue;
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_DEBUG_C)
|
#if defined(MBEDTLS_DEBUG_C)
|
||||||
if (options->cli_log_fun || options->srv_log_fun) {
|
if (options->cli_log_fun || options->srv_log_fun) {
|
||||||
@@ -2154,9 +2151,8 @@ void mbedtls_test_ssl_perform_handshake(
|
|||||||
if (options->dtls != 0) {
|
if (options->dtls != 0) {
|
||||||
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
|
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
|
||||||
MBEDTLS_SSL_IS_CLIENT,
|
MBEDTLS_SSL_IS_CLIENT,
|
||||||
options, NULL,
|
options, NULL, NULL,
|
||||||
&client_queue,
|
NULL), 0);
|
||||||
&server_queue), 0);
|
|
||||||
} else {
|
} else {
|
||||||
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
|
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client,
|
||||||
MBEDTLS_SSL_IS_CLIENT,
|
MBEDTLS_SSL_IS_CLIENT,
|
||||||
@@ -2170,9 +2166,8 @@ void mbedtls_test_ssl_perform_handshake(
|
|||||||
if (options->dtls != 0) {
|
if (options->dtls != 0) {
|
||||||
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
|
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
|
||||||
MBEDTLS_SSL_IS_SERVER,
|
MBEDTLS_SSL_IS_SERVER,
|
||||||
options, NULL,
|
options, NULL, NULL,
|
||||||
&server_queue,
|
NULL), 0);
|
||||||
&client_queue), 0);
|
|
||||||
} else {
|
} else {
|
||||||
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
|
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server,
|
||||||
MBEDTLS_SSL_IS_SERVER,
|
MBEDTLS_SSL_IS_SERVER,
|
||||||
|
|||||||
Reference in New Issue
Block a user