mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 11:55:34 +00:00
Introduce function to parse total handshake length
This commit introduces a static helper function ssl_get_hs_total_len() parsing the total message length field in the handshake header, and puts it to use in mbedtls_ssl_prepare_handshake_record().
This commit is contained in:
parent
0271f967d6
commit
12555c61d3
|
@ -55,6 +55,7 @@
|
|||
#endif
|
||||
|
||||
static void ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl );
|
||||
static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context *ssl );
|
||||
|
||||
/* Length of the "epoch" field in the record header */
|
||||
static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl )
|
||||
|
@ -3659,6 +3660,12 @@ static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl )
|
|||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
return( ( ssl->in_msg[1] << 16 ) |
|
||||
( ssl->in_msg[2] << 8 ) |
|
||||
ssl->in_msg[3] );
|
||||
}
|
||||
|
||||
int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
|
@ -3669,10 +3676,7 @@ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl )
|
|||
return( MBEDTLS_ERR_SSL_INVALID_RECORD );
|
||||
}
|
||||
|
||||
ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + (
|
||||
( ssl->in_msg[1] << 16 ) |
|
||||
( ssl->in_msg[2] << 8 ) |
|
||||
ssl->in_msg[3] );
|
||||
ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ssl_get_hs_total_len( ssl );
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "handshake message: msglen ="
|
||||
" %d, type = %d, hslen = %d",
|
||||
|
|
Loading…
Reference in a new issue