Fix variable names in ssl_tls13_generic/client.c
Signed-off-by: Xiaofei Bai <xiaofei.bai@arm.com>
This commit is contained in:
parent
746f9481ea
commit
eef150418f
2 changed files with 44 additions and 44 deletions
|
@ -152,9 +152,9 @@ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
for ( ; *group_list != 0; group_list++ )
|
for ( ; *group_list != 0; group_list++ )
|
||||||
{
|
{
|
||||||
const mbedtls_ecp_curve_info *info;
|
const mbedtls_ecp_curve_info *curve_info;
|
||||||
info = mbedtls_ecp_curve_info_from_tls_id( *group_list );
|
curve_info = mbedtls_ecp_curve_info_from_tls_id( *group_list );
|
||||||
if( info == NULL )
|
if( curve_info == NULL )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( !mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) )
|
if( !mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) )
|
||||||
|
@ -165,7 +165,7 @@ static int ssl_tls13_write_named_group_list_ecdhe( mbedtls_ssl_context *ssl,
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "NamedGroup: %s ( %x )",
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "NamedGroup: %s ( %x )",
|
||||||
info->name, *group_list ) );
|
curve_info->name, *group_list ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
*olen = p - buf;
|
*olen = p - buf;
|
||||||
|
@ -205,8 +205,8 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl,
|
||||||
size_t *olen )
|
size_t *olen )
|
||||||
{
|
{
|
||||||
unsigned char *p = buf ;
|
unsigned char *p = buf ;
|
||||||
unsigned char *named_group_list_ptr; /* Start of named_group_list */
|
unsigned char *named_group_list; /* Start of named_group_list */
|
||||||
size_t named_group_list_len; /* Length of named_group_list */
|
size_t named_group_list_len; /* Length of named_group_list */
|
||||||
size_t output_len = 0;
|
size_t output_len = 0;
|
||||||
int ret_ecdhe, ret_dhe;
|
int ret_ecdhe, ret_dhe;
|
||||||
|
|
||||||
|
@ -218,14 +218,14 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl,
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_groups extension" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, adding supported_groups extension" ) );
|
||||||
|
|
||||||
/* Check if we have space for header and length fields:
|
/* Check if we have space for header and length fields:
|
||||||
* - extension_type (2 bytes)
|
* - extension_type (2 bytes)
|
||||||
* - extension_data_length (2 bytes)
|
* - extension_data_length (2 bytes)
|
||||||
* - named_group_list_length (2 bytes)
|
* - named_group_list_length (2 bytes)
|
||||||
*/
|
*/
|
||||||
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 );
|
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 6 );
|
||||||
p += 6;
|
p += 6;
|
||||||
|
|
||||||
named_group_list_ptr = p;
|
named_group_list = p;
|
||||||
ret_ecdhe = ssl_tls13_write_named_group_list_ecdhe( ssl, p, end, &output_len );
|
ret_ecdhe = ssl_tls13_write_named_group_list_ecdhe( ssl, p, end, &output_len );
|
||||||
if( ret_ecdhe != 0 )
|
if( ret_ecdhe != 0 )
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,7 @@ static int ssl_tls13_write_supported_groups_ext( mbedtls_ssl_context *ssl,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Length of named_group_list*/
|
/* Length of named_group_list*/
|
||||||
named_group_list_len = p - named_group_list_ptr;
|
named_group_list_len = p - named_group_list;
|
||||||
if( named_group_list_len == 0 )
|
if( named_group_list_len == 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No group available." ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No group available." ) );
|
||||||
|
@ -327,9 +327,9 @@ static int ssl_tls13_get_default_group_id( mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
for ( ; *group_list != 0; group_list++ )
|
for ( ; *group_list != 0; group_list++ )
|
||||||
{
|
{
|
||||||
const mbedtls_ecp_curve_info *info;
|
const mbedtls_ecp_curve_info *curve_info;
|
||||||
info = mbedtls_ecp_curve_info_from_tls_id( *group_list );
|
curve_info = mbedtls_ecp_curve_info_from_tls_id( *group_list );
|
||||||
if( info != NULL &&
|
if( curve_info != NULL &&
|
||||||
mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) )
|
mbedtls_ssl_tls13_named_group_is_ecdhe( *group_list ) )
|
||||||
{
|
{
|
||||||
*group_id = *group_list;
|
*group_id = *group_list;
|
||||||
|
@ -368,8 +368,8 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl,
|
||||||
size_t *olen )
|
size_t *olen )
|
||||||
{
|
{
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
unsigned char *client_shares_ptr; /* Start of client_shares */
|
unsigned char *client_shares; /* Start of client_shares */
|
||||||
size_t client_shares_len; /* Length of client_shares */
|
size_t client_shares_len; /* Length of client_shares */
|
||||||
uint16_t group_id;
|
uint16_t group_id;
|
||||||
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
|
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||||
|
|
||||||
|
@ -405,12 +405,12 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl,
|
||||||
* type of KEM, and dispatch to the corresponding crypto. And
|
* type of KEM, and dispatch to the corresponding crypto. And
|
||||||
* only one key share entry is allowed.
|
* only one key share entry is allowed.
|
||||||
*/
|
*/
|
||||||
client_shares_ptr = p;
|
client_shares = p;
|
||||||
#if defined(MBEDTLS_ECDH_C)
|
#if defined(MBEDTLS_ECDH_C)
|
||||||
if( mbedtls_ssl_tls13_named_group_is_ecdhe( group_id ) )
|
if( mbedtls_ssl_tls13_named_group_is_ecdhe( group_id ) )
|
||||||
{
|
{
|
||||||
/* Pointer to group */
|
/* Pointer to group */
|
||||||
unsigned char *group_ptr = p;
|
unsigned char *group = p;
|
||||||
/* Length of key_exchange */
|
/* Length of key_exchange */
|
||||||
size_t key_exchange_len;
|
size_t key_exchange_len;
|
||||||
|
|
||||||
|
@ -428,9 +428,9 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl,
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
/* Write group */
|
/* Write group */
|
||||||
MBEDTLS_PUT_UINT16_BE( group_id, group_ptr, 0 );
|
MBEDTLS_PUT_UINT16_BE( group_id, group, 0 );
|
||||||
/* Write key_exchange_length */
|
/* Write key_exchange_length */
|
||||||
MBEDTLS_PUT_UINT16_BE( key_exchange_len, group_ptr, 2 );
|
MBEDTLS_PUT_UINT16_BE( key_exchange_len, group, 2 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* MBEDTLS_ECDH_C */
|
#endif /* MBEDTLS_ECDH_C */
|
||||||
|
@ -442,7 +442,7 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl,
|
||||||
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
|
||||||
|
|
||||||
/* Length of client_shares */
|
/* Length of client_shares */
|
||||||
client_shares_len = p - client_shares_ptr;
|
client_shares_len = p - client_shares;
|
||||||
if( client_shares_len == 0)
|
if( client_shares_len == 0)
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No key share defined." ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No key share defined." ) );
|
||||||
|
@ -604,7 +604,7 @@ static int ssl_tls13_write_client_hello_cipher_suites(
|
||||||
{
|
{
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
const int *ciphersuite_list;
|
const int *ciphersuite_list;
|
||||||
unsigned char *cipher_suites_ptr; /* Start of the cipher_suites list */
|
unsigned char *cipher_suites; /* Start of the cipher_suites list */
|
||||||
size_t cipher_suites_len;
|
size_t cipher_suites_len;
|
||||||
|
|
||||||
*olen = 0 ;
|
*olen = 0 ;
|
||||||
|
@ -624,7 +624,7 @@ static int ssl_tls13_write_client_hello_cipher_suites(
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
||||||
/* Write cipher_suites */
|
/* Write cipher_suites */
|
||||||
cipher_suites_ptr = p;
|
cipher_suites = p;
|
||||||
for ( size_t i = 0; ciphersuite_list[i] != 0; i++ )
|
for ( size_t i = 0; ciphersuite_list[i] != 0; i++ )
|
||||||
{
|
{
|
||||||
int cipher_suite = ciphersuite_list[i];
|
int cipher_suite = ciphersuite_list[i];
|
||||||
|
@ -648,7 +648,7 @@ static int ssl_tls13_write_client_hello_cipher_suites(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the cipher_suites length in number of bytes */
|
/* Write the cipher_suites length in number of bytes */
|
||||||
cipher_suites_len = p - cipher_suites_ptr;
|
cipher_suites_len = p - cipher_suites;
|
||||||
MBEDTLS_PUT_UINT16_BE( cipher_suites_len, buf, 0 );
|
MBEDTLS_PUT_UINT16_BE( cipher_suites_len, buf, 0 );
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3,
|
MBEDTLS_SSL_DEBUG_MSG( 3,
|
||||||
( "client hello, got %" MBEDTLS_PRINTF_SIZET " cipher suites",
|
( "client hello, got %" MBEDTLS_PRINTF_SIZET " cipher suites",
|
||||||
|
@ -679,9 +679,9 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl,
|
||||||
{
|
{
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char *extensions_len_ptr; /* Pointer to extensions length */
|
unsigned char *p_extensions_len; /* Pointer to extensions length */
|
||||||
size_t output_len; /* Length of buffer used by function */
|
size_t output_len; /* Length of buffer used by function */
|
||||||
size_t extensions_len; /* Length of the list of extensions*/
|
size_t extensions_len; /* Length of the list of extensions*/
|
||||||
|
|
||||||
/* Buffer management */
|
/* Buffer management */
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
|
@ -749,7 +749,7 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl,
|
||||||
|
|
||||||
/* First write extensions, then the total length */
|
/* First write extensions, then the total length */
|
||||||
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 );
|
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 );
|
||||||
extensions_len_ptr = p;
|
p_extensions_len = p;
|
||||||
p += 2;
|
p += 2;
|
||||||
|
|
||||||
/* Write supported_versions extension
|
/* Write supported_versions extension
|
||||||
|
@ -809,11 +809,11 @@ static int ssl_tls13_write_client_hello_body( mbedtls_ssl_context *ssl,
|
||||||
/* Add more extensions here */
|
/* Add more extensions here */
|
||||||
|
|
||||||
/* Write the length of the list of extensions. */
|
/* Write the length of the list of extensions. */
|
||||||
extensions_len = p - extensions_len_ptr - 2;
|
extensions_len = p - p_extensions_len - 2;
|
||||||
MBEDTLS_PUT_UINT16_BE( extensions_len, extensions_len_ptr, 0 );
|
MBEDTLS_PUT_UINT16_BE( extensions_len, p_extensions_len, 0 );
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET ,
|
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, total extension length: %" MBEDTLS_PRINTF_SIZET ,
|
||||||
extensions_len ) );
|
extensions_len ) );
|
||||||
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", extensions_len_ptr, extensions_len );
|
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello extensions", p_extensions_len, extensions_len );
|
||||||
|
|
||||||
*olen = p - buf;
|
*olen = p - buf;
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
unsigned hs_type,
|
unsigned hs_type,
|
||||||
unsigned char **buf,
|
unsigned char **buf,
|
||||||
size_t *buflen )
|
size_t *buf_len )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ int mbedtls_ssl_tls13_fetch_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
* uint24 length;
|
* uint24 length;
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
*buf = ssl->in_msg + 4;
|
*buf = ssl->in_msg + 4;
|
||||||
*buflen = ssl->in_hslen - 4;
|
*buf_len = ssl->in_hslen - 4;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
|
@ -99,12 +99,12 @@ int mbedtls_ssl_tls13_finish_handshake_msg( mbedtls_ssl_context *ssl,
|
||||||
size_t msg_len )
|
size_t msg_len )
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
size_t msg_len_with_header;
|
size_t msg_with_header_len;
|
||||||
((void) buf_len);
|
((void) buf_len);
|
||||||
|
|
||||||
/* Add reserved 4 bytes for handshake header */
|
/* Add reserved 4 bytes for handshake header */
|
||||||
msg_len_with_header = msg_len + 4;
|
msg_with_header_len = msg_len + 4;
|
||||||
ssl->out_msglen = msg_len_with_header;
|
ssl->out_msglen = msg_with_header_len;
|
||||||
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) );
|
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_write_handshake_msg_ext( ssl, 0 ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -160,8 +160,8 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl,
|
||||||
size_t *olen )
|
size_t *olen )
|
||||||
{
|
{
|
||||||
unsigned char *p = buf;
|
unsigned char *p = buf;
|
||||||
unsigned char *supported_sig_alg_ptr; /* Start of supported_signature_algorithms */
|
unsigned char *supported_sig_alg; /* Start of supported_signature_algorithms */
|
||||||
size_t supported_sig_alg_len = 0; /* Length of supported_signature_algorithms */
|
size_t supported_sig_alg_len = 0; /* Length of supported_signature_algorithms */
|
||||||
|
|
||||||
*olen = 0;
|
*olen = 0;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl,
|
||||||
/*
|
/*
|
||||||
* Write supported_signature_algorithms
|
* Write supported_signature_algorithms
|
||||||
*/
|
*/
|
||||||
supported_sig_alg_ptr = p;
|
supported_sig_alg = p;
|
||||||
for( const uint16_t *sig_alg = ssl->conf->tls13_sig_algs;
|
for( const uint16_t *sig_alg = ssl->conf->tls13_sig_algs;
|
||||||
*sig_alg != MBEDTLS_TLS1_3_SIG_NONE; sig_alg++ )
|
*sig_alg != MBEDTLS_TLS1_3_SIG_NONE; sig_alg++ )
|
||||||
{
|
{
|
||||||
|
@ -199,7 +199,7 @@ int mbedtls_ssl_tls13_write_sig_alg_ext( mbedtls_ssl_context *ssl,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Length of supported_signature_algorithms */
|
/* Length of supported_signature_algorithms */
|
||||||
supported_sig_alg_len = p - supported_sig_alg_ptr;
|
supported_sig_alg_len = p - supported_sig_alg;
|
||||||
if( supported_sig_alg_len == 0 )
|
if( supported_sig_alg_len == 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No signature algorithms defined." ) );
|
MBEDTLS_SSL_DEBUG_MSG( 1, ( "No signature algorithms defined." ) );
|
||||||
|
@ -1020,7 +1020,7 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
size_t buflen;
|
size_t buf_len;
|
||||||
|
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished message" ) );
|
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse finished message" ) );
|
||||||
|
|
||||||
|
@ -1029,10 +1029,10 @@ int mbedtls_ssl_tls13_process_finished_message( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_fetch_handshake_msg( ssl,
|
MBEDTLS_SSL_PROC_CHK( mbedtls_ssl_tls13_fetch_handshake_msg( ssl,
|
||||||
MBEDTLS_SSL_HS_FINISHED,
|
MBEDTLS_SSL_HS_FINISHED,
|
||||||
&buf, &buflen ) );
|
&buf, &buf_len ) );
|
||||||
MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_message( ssl, buf, buf + buflen ) );
|
MBEDTLS_SSL_PROC_CHK( ssl_tls13_parse_finished_message( ssl, buf, buf + buf_len ) );
|
||||||
mbedtls_ssl_tls13_add_hs_msg_to_checksum(
|
mbedtls_ssl_tls13_add_hs_msg_to_checksum(
|
||||||
ssl, MBEDTLS_SSL_HS_FINISHED, buf, buflen );
|
ssl, MBEDTLS_SSL_HS_FINISHED, buf, buf_len );
|
||||||
MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_finished_message( ssl ) );
|
MBEDTLS_SSL_PROC_CHK( ssl_tls13_postprocess_finished_message( ssl ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
Loading…
Reference in a new issue