mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-29 22:20:30 +00:00
Merge pull request #4977 from xkqian/generic_fetch_handshake_msg
Add fetch_hand_message in generic
This commit is contained in:
commit
d8ca055073
@ -1489,6 +1489,14 @@ static inline void mbedtls_ssl_handshake_set_state( mbedtls_ssl_context *ssl,
|
|||||||
ssl->state = ( int ) state;
|
ssl->state = ( int ) state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fetch TLS 1.3 handshake message header
|
||||||
|
*/
|
||||||
|
int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
|
unsigned hs_type,
|
||||||
|
unsigned char **buf,
|
||||||
|
size_t *buf_len );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write TLS 1.3 handshake message header
|
* Write TLS 1.3 handshake message header
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,44 @@
|
|||||||
|
|
||||||
#include "ssl_misc.h"
|
#include "ssl_misc.h"
|
||||||
|
|
||||||
|
int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
|
unsigned hs_type,
|
||||||
|
unsigned char **buf,
|
||||||
|
size_t *buflen )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if( ( ret = mbedtls_ssl_read_record( ssl, 0 ) ) != 0 )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ||
|
||||||
|
ssl->in_msg[0] != hs_type )
|
||||||
|
{
|
||||||
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "Receive unexpected handshake message." ) );
|
||||||
|
MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE,
|
||||||
|
MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
|
||||||
|
ret = MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Jump handshake header (4 bytes, see Section 4 of RFC 8446).
|
||||||
|
* ...
|
||||||
|
* HandshakeType msg_type;
|
||||||
|
* uint24 length;
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
*buf = ssl->in_msg + 4;
|
||||||
|
*buflen = ssl->in_hslen - 4;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
|
int mbedtls_ssl_tls13_start_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
unsigned hs_type,
|
unsigned hs_type,
|
||||||
unsigned char **buf,
|
unsigned char **buf,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user