Ignore early data app msg before 2nd client hello
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com> Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
263dbf7167
commit
f57d14bed4
3 changed files with 53 additions and 3 deletions
|
@ -4109,6 +4109,32 @@ static int ssl_prepare_record_content(mbedtls_ssl_context *ssl,
|
|||
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_SRV_C)
|
||||
/*
|
||||
* Although the server rejected early data because it needed to send an
|
||||
* HelloRetryRequest message, it might receive early data as long as it has
|
||||
* not received the client Finished message.
|
||||
* The early data is encrypted with early keys and should be ignored as
|
||||
* stated in section 4.2.10 of RFC 8446 (second case):
|
||||
*
|
||||
* "The server then ignores early data by skipping all records with an
|
||||
* external content type of "application_data" (indicating that they are
|
||||
* encrypted), up to the configured max_early_data_size. Ignore application
|
||||
* data message before 2nd ClientHello when early_data was received in 1st
|
||||
* ClientHello."
|
||||
*/
|
||||
if (ssl->discard_early_data_record == MBEDTLS_SSL_EARLY_DATA_DISCARD) {
|
||||
if (rec->type == MBEDTLS_SSL_MSG_APPLICATION_DATA) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(
|
||||
3, ("EarlyData: Ignore application message before 2nd ClientHello"));
|
||||
/* TODO: Add max_early_data_size check here. */
|
||||
return MBEDTLS_ERR_SSL_CONTINUE_PROCESSING;
|
||||
} else if (rec->type == MBEDTLS_SSL_MSG_HANDSHAKE) {
|
||||
ssl->discard_early_data_record = MBEDTLS_SSL_EARLY_DATA_NO_DISCARD;
|
||||
}
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
if (ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM) {
|
||||
mbedtls_ssl_dtls_replay_update(ssl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue