mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-15 23:42:41 +00:00
tests: read early data: Use write API to send early data
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
110303fbe5
commit
7d158f41ca
@ -18,49 +18,6 @@
|
||||
#define TEST_EARLY_DATA_SERVER_REJECTS 2
|
||||
#define TEST_EARLY_DATA_HRR 3
|
||||
|
||||
#if (!defined(MBEDTLS_SSL_PROTO_TLS1_2)) && \
|
||||
defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_CLI_C) && \
|
||||
defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_DEBUG_C) && \
|
||||
defined(MBEDTLS_TEST_AT_LEAST_ONE_TLS1_3_CIPHERSUITE) && \
|
||||
defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED) && \
|
||||
defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED) && \
|
||||
defined(MBEDTLS_MD_CAN_SHA256) && \
|
||||
defined(MBEDTLS_ECP_HAVE_SECP256R1) && defined(MBEDTLS_ECP_HAVE_SECP384R1) && \
|
||||
defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) && defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
/*
|
||||
* The implementation of the function should be based on
|
||||
* mbedtls_ssl_write_early_data() eventually. The current version aims at
|
||||
* removing the dependency on mbedtls_ssl_write_early_data() for the
|
||||
* development and testing of reading early data.
|
||||
*/
|
||||
static int write_early_data(mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf, size_t len)
|
||||
{
|
||||
int ret = mbedtls_ssl_get_max_out_record_payload(ssl);
|
||||
|
||||
TEST_ASSERT(ret > 0);
|
||||
TEST_ASSERT(len <= (size_t) ret);
|
||||
|
||||
ret = mbedtls_ssl_flush_output(ssl);
|
||||
TEST_EQUAL(ret, 0);
|
||||
TEST_EQUAL(ssl->out_left, 0);
|
||||
|
||||
ssl->out_msglen = len;
|
||||
ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA;
|
||||
if (len > 0) {
|
||||
memcpy(ssl->out_msg, buf, len);
|
||||
}
|
||||
|
||||
ret = mbedtls_ssl_write_record(ssl, 1);
|
||||
TEST_EQUAL(ret, 0);
|
||||
|
||||
ret = len;
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
@ -3750,11 +3707,15 @@ void tls13_read_early_data(int scenario)
|
||||
&(client_ep.ssl), &(server_ep.ssl),
|
||||
MBEDTLS_SSL_SERVER_HELLO), 0);
|
||||
|
||||
ret = mbedtls_ssl_write_early_data(&(client_ep.ssl),
|
||||
(unsigned char *) early_data,
|
||||
early_data_len);
|
||||
|
||||
if (client_ep.ssl.early_data_status !=
|
||||
MBEDTLS_SSL_EARLY_DATA_STATUS_NOT_SENT) {
|
||||
ret = write_early_data(&(client_ep.ssl), (unsigned char *) early_data,
|
||||
early_data_len);
|
||||
TEST_EQUAL(ret, early_data_len);
|
||||
} else {
|
||||
TEST_EQUAL(ret, MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA);
|
||||
}
|
||||
|
||||
ret = mbedtls_test_move_handshake_to_state(
|
||||
|
Loading…
x
Reference in New Issue
Block a user