Fix some issues such as naming mismatch based on comments.

Signed-off-by: XiaokangQian <xiaokang.qian@arm.com>
This commit is contained in:
XiaokangQian 2021-09-24 07:35:32 +00:00
parent c1fe000cfd
commit e87e5924c9
2 changed files with 10 additions and 47 deletions

View File

@ -1406,20 +1406,19 @@ cleanup:
/*
* Overview
*/
static int ssl_tls1_3_read_encrypted_extensions( mbedtls_ssl_context *ssl );
/* Main entry point; orchestrates the other functions */
static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl );
static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl );
static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl,
static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl,
const unsigned char *buf,
size_t buf_len );
static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl );
static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl );
/*
* Handler for MBEDTLS_SSL_ENCRYPTED_EXTENSIONS
*/
static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl )
static int ssl_tls1_3_process_encrypted_extensions( mbedtls_ssl_context *ssl )
{
int ret;
unsigned char *buf;
@ -1427,17 +1426,17 @@ static int ssl_tls13_encrypted_extensions_process( mbedtls_ssl_context *ssl )
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse encrypted extensions" ) );
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_fetch_handshake_msg( ssl,
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls1_3_fetch_handshake_msg( ssl,
MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION,
&buf, &buf_len ) );
/* Process the message contents */
MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_parse( ssl, buf, buf_len ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_parse_encrypted_extensions( ssl, buf, buf_len ) );
mbedtls_ssl_tls13_add_hs_msg_to_checksum(
mbedtls_ssl_tls1_3_add_hs_msg_to_checksum(
ssl, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSION, buf, buf_len );
MBEDTLS_SSL_PROC_CHK( ssl_tls13_encrypted_extensions_postprocess( ssl ) );
MBEDTLS_SSL_PROC_CHK( ssl_tls1_3_postprocess_encrypted_extensions( ssl ) );
cleanup:
@ -1446,7 +1445,7 @@ cleanup:
}
static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl,
static int ssl_tls1_3_parse_encrypted_extensions( mbedtls_ssl_context *ssl,
const unsigned char *buf,
size_t buf_len )
{
@ -1512,7 +1511,7 @@ static int ssl_tls13_encrypted_extensions_parse( mbedtls_ssl_context *ssl,
return( ret );
}
static int ssl_tls13_encrypted_extensions_postprocess( mbedtls_ssl_context *ssl )
static int ssl_tls1_3_postprocess_encrypted_extensions( mbedtls_ssl_context *ssl )
{
mbedtls_ssl_handshake_set_state( ssl, MBEDTLS_SSL_CERTIFICATE_REQUEST );
return( 0 );
@ -1669,10 +1668,6 @@ int mbedtls_ssl_tls13_handshake_client_step( mbedtls_ssl_context *ssl )
ret = ssl_tls1_3_handshake_wrapup( ssl );
break;
case MBEDTLS_SSL_ENCRYPTED_EXTENSIONS:
ret = ssl_tls13_encrypted_extensions_process( ssl );
break;
default:
MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid state %d", ssl->state ) );
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );

View File

@ -29,38 +29,6 @@
#include "ssl_misc.h"
#include <mbedtls/debug.h>
int mbedtls_ssl_tls13_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, ( "bad certificate verify 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;
}
*buf = ssl->in_msg + 4;
*buflen = ssl->in_hslen - 4;
cleanup:
return( ret );
}
int mbedtls_ssl_tls1_3_fetch_handshake_msg( mbedtls_ssl_context *ssl,
unsigned hs_type,
unsigned char **buf,