Normalize "should never happen" messages/errors
This commit is contained in:
parent
79e69f94d6
commit
61edffef28
3 changed files with 39 additions and 42 deletions
|
@ -1251,8 +1251,8 @@ static int ssl_check_server_ecdh_params( const ssl_context *ssl )
|
|||
curve_info = ecp_curve_info_from_grp_id( ssl->handshake->ecdh_ctx.grp.id );
|
||||
if( curve_info == NULL )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "Should never happen" ) );
|
||||
return( -1 );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) );
|
||||
|
@ -1634,7 +1634,7 @@ static int ssl_parse_server_key_exchange( ssl_context *ssl )
|
|||
POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
|
||||
|
@ -1681,7 +1681,7 @@ static int ssl_parse_server_key_exchange( ssl_context *ssl )
|
|||
#endif
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1770,7 +1770,7 @@ static int ssl_parse_server_key_exchange( ssl_context *ssl )
|
|||
POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen :
|
||||
|
@ -1810,7 +1810,6 @@ exit:
|
|||
!defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
static int ssl_parse_certificate_request( ssl_context *ssl )
|
||||
{
|
||||
int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
const ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) );
|
||||
|
@ -1825,8 +1824,8 @@ static int ssl_parse_certificate_request( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else
|
||||
static int ssl_parse_certificate_request( ssl_context *ssl )
|
||||
|
@ -2184,7 +2183,7 @@ static int ssl_write_client_key_exchange( ssl_context *ssl )
|
|||
#endif /* POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
if( ( ret = ssl_psk_derive_premaster( ssl,
|
||||
|
@ -2208,7 +2207,7 @@ static int ssl_write_client_key_exchange( ssl_context *ssl )
|
|||
{
|
||||
((void) ciphersuite_info);
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
if( ( ret = ssl_derive_keys( ssl ) ) != 0 )
|
||||
|
@ -2240,7 +2239,6 @@ static int ssl_write_client_key_exchange( ssl_context *ssl )
|
|||
!defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
static int ssl_write_certificate_verify( ssl_context *ssl )
|
||||
{
|
||||
int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
const ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) );
|
||||
|
@ -2255,8 +2253,8 @@ static int ssl_write_certificate_verify( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else
|
||||
static int ssl_write_certificate_verify( ssl_context *ssl )
|
||||
|
@ -2370,7 +2368,7 @@ static int ssl_write_certificate_verify( ssl_context *ssl )
|
|||
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
if( ( ret = pk_sign( ssl_own_key( ssl ), md_alg, hash_start, hashlen,
|
||||
|
|
|
@ -1951,7 +1951,6 @@ static int ssl_write_server_hello( ssl_context *ssl )
|
|||
!defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||
static int ssl_write_certificate_request( ssl_context *ssl )
|
||||
{
|
||||
int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
const ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) );
|
||||
|
@ -1966,8 +1965,8 @@ static int ssl_write_certificate_request( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else
|
||||
static int ssl_write_certificate_request( ssl_context *ssl )
|
||||
|
@ -2329,7 +2328,7 @@ curve_matching_done:
|
|||
if( md_alg == POLARSSL_MD_NONE )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2424,7 +2423,7 @@ curve_matching_done:
|
|||
POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen :
|
||||
|
@ -2916,7 +2915,7 @@ static int ssl_parse_client_key_exchange( ssl_context *ssl )
|
|||
#endif /* POLARSSL_KEY_EXCHANGE_RSA_ENABLED */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
if( ( ret = ssl_derive_keys( ssl ) ) != 0 )
|
||||
|
@ -2953,8 +2952,8 @@ static int ssl_parse_certificate_verify( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else
|
||||
static int ssl_parse_certificate_verify( ssl_context *ssl )
|
||||
|
@ -3084,7 +3083,7 @@ static int ssl_parse_certificate_verify( ssl_context *ssl )
|
|||
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
sig_len = ( ssl->in_msg[4 + sa_len] << 8 ) | ssl->in_msg[5 + sa_len];
|
||||
|
|
|
@ -444,7 +444,7 @@ int ssl_derive_keys( ssl_context *ssl )
|
|||
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -608,7 +608,7 @@ int ssl_derive_keys( ssl_context *ssl )
|
|||
if( transform->maclen > sizeof transform->mac_enc )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
memcpy( transform->mac_enc, mac_enc, transform->maclen );
|
||||
|
@ -627,7 +627,7 @@ int ssl_derive_keys( ssl_context *ssl )
|
|||
#endif
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
|
||||
|
@ -922,7 +922,7 @@ int ssl_psk_derive_premaster( ssl_context *ssl, key_exchange_type_t key_ex )
|
|||
#endif /* POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
/* opaque psk<0..2^16-1>; */
|
||||
|
@ -1028,7 +1028,7 @@ static int ssl_encrypt_buf( ssl_context *ssl )
|
|||
#endif
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_BUF( 4, "computed mac",
|
||||
|
@ -1186,7 +1186,7 @@ static int ssl_encrypt_buf( ssl_context *ssl )
|
|||
if( totlen != enc_msglen )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( -1 );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1316,7 +1316,7 @@ static int ssl_encrypt_buf( ssl_context *ssl )
|
|||
( POLARSSL_AES_C || POLARSSL_CAMELLIA_C ) */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
for( i = 8; i > 0; i-- )
|
||||
|
@ -1477,7 +1477,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
|
|||
if( totlen != dec_msglen )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( -1 );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1673,7 +1673,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
|
|||
POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1681,7 +1681,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
|
|||
( POLARSSL_AES_C || POLARSSL_CAMELLIA_C ) */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_BUF( 4, "raw buffer after decryption",
|
||||
|
@ -1753,7 +1753,7 @@ static int ssl_decrypt_buf( ssl_context *ssl )
|
|||
POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
SSL_DEBUG_BUF( 4, "message mac", tmp, ssl->transform_in->maclen );
|
||||
|
@ -2396,7 +2396,6 @@ int ssl_send_alert_message( ssl_context *ssl,
|
|||
!defined(POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
|
||||
int ssl_write_certificate( ssl_context *ssl )
|
||||
{
|
||||
int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
const ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "=> write certificate" ) );
|
||||
|
@ -2410,13 +2409,12 @@ int ssl_write_certificate( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
|
||||
int ssl_parse_certificate( ssl_context *ssl )
|
||||
{
|
||||
int ret = POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE;
|
||||
const ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
|
||||
|
||||
SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) );
|
||||
|
@ -2430,8 +2428,8 @@ int ssl_parse_certificate( ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 1, ( "should not happen" ) );
|
||||
return( ret );
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
#else
|
||||
int ssl_write_certificate( ssl_context *ssl )
|
||||
|
@ -2864,8 +2862,10 @@ void ssl_optimize_checksum( ssl_context *ssl,
|
|||
else
|
||||
#endif
|
||||
#endif /* POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
/* Should never happen */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void ssl_update_checksum_start( ssl_context *ssl,
|
||||
|
@ -4387,7 +4387,7 @@ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len )
|
|||
POLARSSL_SSL_PROTO_TLS1_2 */
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "should never happen" ) );
|
||||
return( POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE );
|
||||
return( POLARSSL_ERR_SSL_INTERNAL_ERROR );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue