refactor parse key_share ext
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
fbe3e64b76
commit
086edc2807
1 changed files with 4 additions and 4 deletions
|
@ -203,6 +203,7 @@ static int ssl_tls13_parse_key_shares_ext( mbedtls_ssl_context *ssl,
|
||||||
{
|
{
|
||||||
uint16_t group;
|
uint16_t group;
|
||||||
size_t key_exchange_len;
|
size_t key_exchange_len;
|
||||||
|
const unsigned char *key_exchange;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* struct {
|
* struct {
|
||||||
|
@ -214,7 +215,9 @@ static int ssl_tls13_parse_key_shares_ext( mbedtls_ssl_context *ssl,
|
||||||
group = MBEDTLS_GET_UINT16_BE( p, 0 );
|
group = MBEDTLS_GET_UINT16_BE( p, 0 );
|
||||||
key_exchange_len = MBEDTLS_GET_UINT16_BE( p, 2 );
|
key_exchange_len = MBEDTLS_GET_UINT16_BE( p, 2 );
|
||||||
p += 4;
|
p += 4;
|
||||||
|
key_exchange = p;
|
||||||
MBEDTLS_SSL_CHK_BUF_READ_PTR( p, client_shares_end, key_exchange_len );
|
MBEDTLS_SSL_CHK_BUF_READ_PTR( p, client_shares_end, key_exchange_len );
|
||||||
|
p += key_exchange_len;
|
||||||
|
|
||||||
/* Continue parsing even if we have already found a match,
|
/* Continue parsing even if we have already found a match,
|
||||||
* for input validation purposes.
|
* for input validation purposes.
|
||||||
|
@ -223,7 +226,6 @@ static int ssl_tls13_parse_key_shares_ext( mbedtls_ssl_context *ssl,
|
||||||
! mbedtls_ssl_named_group_is_supported( group ) ||
|
! mbedtls_ssl_named_group_is_supported( group ) ||
|
||||||
ssl->handshake->offered_group_id != 0 )
|
ssl->handshake->offered_group_id != 0 )
|
||||||
{
|
{
|
||||||
p += key_exchange_len;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +238,7 @@ static int ssl_tls13_parse_key_shares_ext( mbedtls_ssl_context *ssl,
|
||||||
mbedtls_ssl_named_group_to_str( group ),
|
mbedtls_ssl_named_group_to_str( group ),
|
||||||
group ) );
|
group ) );
|
||||||
ret = mbedtls_ssl_tls13_read_public_ecdhe_share(
|
ret = mbedtls_ssl_tls13_read_public_ecdhe_share(
|
||||||
ssl, p - 2, key_exchange_len + 2 );
|
ssl, key_exchange - 2, key_exchange_len + 2 );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
|
@ -245,12 +247,10 @@ static int ssl_tls13_parse_key_shares_ext( mbedtls_ssl_context *ssl,
|
||||||
{
|
{
|
||||||
MBEDTLS_SSL_DEBUG_MSG( 4, ( "Unrecognized NamedGroup %u",
|
MBEDTLS_SSL_DEBUG_MSG( 4, ( "Unrecognized NamedGroup %u",
|
||||||
(unsigned) group ) );
|
(unsigned) group ) );
|
||||||
p += key_exchange_len;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl->handshake->offered_group_id = group;
|
ssl->handshake->offered_group_id = group;
|
||||||
p += key_exchange_len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue