fix various issues
- adjust guards. Remove duplicate guards and adjust format. - Return success at function end. Not `ret` - change input len Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
21092062f3
commit
6916e70521
2 changed files with 11 additions and 15 deletions
|
@ -837,7 +837,7 @@ static int ssl_tls13_write_binder( mbedtls_ssl_context *ssl,
|
|||
/* Get current state of handshake transcript. */
|
||||
ret = mbedtls_ssl_get_handshake_transcript(
|
||||
ssl, mbedtls_hash_info_md_from_psa( hash_alg ),
|
||||
transcript, MBEDTLS_MD_MAX_SIZE, &transcript_len );
|
||||
transcript, sizeof( transcript ), &transcript_len );
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
|
@ -853,7 +853,7 @@ static int ssl_tls13_write_binder( mbedtls_ssl_context *ssl,
|
|||
|
||||
*out_len = 1 + binder_len;
|
||||
|
||||
return( ret );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -918,12 +918,11 @@ int mbedtls_ssl_tls13_write_identities_of_pre_shared_key_ext(
|
|||
if( ssl_tls13_ticket_get_identity(
|
||||
ssl, &hash_alg, &identity, &identity_len ) == 0 )
|
||||
{
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
uint32_t obfuscated_ticket_age = 0;
|
||||
mbedtls_time_t now = mbedtls_time( NULL );
|
||||
mbedtls_ssl_session *session = ssl->session_negotiate;
|
||||
obfuscated_ticket_age = (uint32_t)( now - session->ticket_received );
|
||||
uint32_t obfuscated_ticket_age =
|
||||
(uint32_t)( now - session->ticket_received );
|
||||
|
||||
obfuscated_ticket_age *= 1000;
|
||||
obfuscated_ticket_age += session->ticket_age_add;
|
||||
|
@ -963,7 +962,7 @@ int mbedtls_ssl_tls13_write_identities_of_pre_shared_key_ext(
|
|||
|
||||
/* Take into account the two bytes for the length of the binders. */
|
||||
l_binders_len += 2;
|
||||
/* Check if there are enough space for binders */
|
||||
/* Check if there is enough space for binders */
|
||||
MBEDTLS_SSL_CHK_BUF_PTR( p, end, l_binders_len );
|
||||
|
||||
/*
|
||||
|
@ -1105,11 +1104,12 @@ static int ssl_tls13_parse_server_pre_shared_key_ext( mbedtls_ssl_context *ssl,
|
|||
if( ret != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_set_hs_psk", ret );
|
||||
return( ret );
|
||||
}
|
||||
else
|
||||
ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_PRE_SHARED_KEY;
|
||||
|
||||
return( ret );
|
||||
ssl->handshake->extensions_present |= MBEDTLS_SSL_EXT_PRE_SHARED_KEY;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED */
|
||||
|
|
|
@ -1353,8 +1353,7 @@ int report_cid_usage( mbedtls_ssl_context *ssl,
|
|||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS) && \
|
||||
defined(MBEDTLS_HAVE_TIME)
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_HAVE_TIME)
|
||||
/* Functions for session ticket tests */
|
||||
int dummy_ticket_write( void *p_ticket, const mbedtls_ssl_session *session,
|
||||
unsigned char *start, const unsigned char *end,
|
||||
|
@ -1400,7 +1399,6 @@ int dummy_ticket_parse( void *p_ticket, mbedtls_ssl_session *session,
|
|||
return( MBEDTLS_ERR_SSL_INVALID_MAC );
|
||||
case 2:
|
||||
return( MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED );
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
case 3:
|
||||
session->start = mbedtls_time( NULL ) + 10;
|
||||
break;
|
||||
|
@ -1416,15 +1414,13 @@ int dummy_ticket_parse( void *p_ticket, mbedtls_ssl_session *session,
|
|||
session->ticket_age_add -= 1000;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS &&
|
||||
MBEDTLS_HAVE_TIME */
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS && MBEDTLS_HAVE_TIME */
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue