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
1 changed files with 8 additions and 4 deletions
|
@ -55,6 +55,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl );
|
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 */
|
/* Length of the "epoch" field in the record header */
|
||||||
static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl )
|
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 */
|
#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 )
|
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 );
|
return( MBEDTLS_ERR_SSL_INVALID_RECORD );
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + (
|
ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ssl_get_hs_total_len( ssl );
|
||||||
( ssl->in_msg[1] << 16 ) |
|
|
||||||
( ssl->in_msg[2] << 8 ) |
|
|
||||||
ssl->in_msg[3] );
|
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "handshake message: msglen ="
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "handshake message: msglen ="
|
||||||
" %d, type = %d, hslen = %d",
|
" %d, type = %d, hslen = %d",
|
||||||
|
|
Loading…
Reference in a new issue