mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08:00
dtls: Fix adaptation to first ClientHello
For each received ClientHello fragment, check that its epoch is zero and update the record-level sequence number. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
7a8fbc2100
commit
1330606ca1
@ -2991,16 +2991,17 @@ int mbedtls_ssl_prepare_handshake_record(mbedtls_ssl_context *ssl)
|
|||||||
ssl_buffering_shift_slots(ssl, recv_msg_seq);
|
ssl_buffering_shift_slots(ssl, recv_msg_seq);
|
||||||
ssl->handshake->in_msg_seq = recv_msg_seq;
|
ssl->handshake->in_msg_seq = recv_msg_seq;
|
||||||
ssl->handshake->out_msg_seq = recv_msg_seq;
|
ssl->handshake->out_msg_seq = recv_msg_seq;
|
||||||
|
|
||||||
/* Epoch should be 0 for initial handshakes */
|
|
||||||
if (ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0) {
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG(1, ("bad client hello message"));
|
|
||||||
return MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&ssl->cur_out_ctr[2], ssl->in_ctr + 2,
|
|
||||||
sizeof(ssl->cur_out_ctr) - 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Epoch should be 0 for initial handshakes */
|
||||||
|
if (ssl->in_ctr[0] != 0 || ssl->in_ctr[1] != 0) {
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG(1, ("bad client hello message"));
|
||||||
|
return MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&ssl->cur_out_ctr[2], ssl->in_ctr + 2,
|
||||||
|
sizeof(ssl->cur_out_ctr) - 2);
|
||||||
|
|
||||||
} else if (mbedtls_ssl_is_handshake_over(ssl) == 1) {
|
} else if (mbedtls_ssl_is_handshake_over(ssl) == 1) {
|
||||||
/* In case of a post-handshake ClientHello that initiates a
|
/* In case of a post-handshake ClientHello that initiates a
|
||||||
* renegotiation check that the handshake message sequence
|
* renegotiation check that the handshake message sequence
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user