ssl_server2: merge redundant async_private_error=resume/pk

Testing the case where the resume callback returns an error at the
beginning and the case where it returns an error at the end is
redundant. Keep the test after the output has been produced, to
validate that the product does not use even a valid output if the
return value is an error code.
This commit is contained in:
Gilles Peskine 2018-04-26 07:15:40 +02:00
parent d3268834f3
commit c912572a7f
2 changed files with 3 additions and 21 deletions

View file

@ -207,7 +207,7 @@ int main( void )
" async_private_delay2=%%d Asynchronous delay for key_file2\n" \ " async_private_delay2=%%d Asynchronous delay for key_file2\n" \
" default: -1 (not asynchronous)\n" \ " default: -1 (not asynchronous)\n" \
" async_private_error=%%d Async callback error injection (default=0=none,\n" \ " async_private_error=%%d Async callback error injection (default=0=none,\n" \
" 1=start, 2=cancel, 3=resume, 4=pk, negative=first time only)" " 1=start, 2=cancel, 3=resume, negative=first time only)"
#else #else
#define USAGE_SSL_ASYNC "" #define USAGE_SSL_ASYNC ""
#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */
@ -875,8 +875,7 @@ typedef enum {
SSL_ASYNC_INJECT_ERROR_START, /*!< Inject error during start */ SSL_ASYNC_INJECT_ERROR_START, /*!< Inject error during start */
SSL_ASYNC_INJECT_ERROR_CANCEL, /*!< Close the connection after async start */ SSL_ASYNC_INJECT_ERROR_CANCEL, /*!< Close the connection after async start */
SSL_ASYNC_INJECT_ERROR_RESUME, /*!< Inject error during resume */ SSL_ASYNC_INJECT_ERROR_RESUME, /*!< Inject error during resume */
SSL_ASYNC_INJECT_ERROR_PK /*!< Inject error during resume */ #define SSL_ASYNC_INJECT_ERROR_MAX SSL_ASYNC_INJECT_ERROR_RESUME
#define SSL_ASYNC_INJECT_ERROR_MAX SSL_ASYNC_INJECT_ERROR_PK
} ssl_async_inject_error_t; } ssl_async_inject_error_t;
typedef struct typedef struct
@ -1019,12 +1018,6 @@ static int ssl_async_resume( void *config_data_arg,
int ret; int ret;
const char *op_name = NULL; const char *op_name = NULL;
if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_RESUME )
{
mbedtls_printf( "Async resume callback: injected error\n" );
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
}
if( ctx->remaining_delay > 0 ) if( ctx->remaining_delay > 0 )
{ {
--ctx->remaining_delay; --ctx->remaining_delay;
@ -1057,7 +1050,7 @@ static int ssl_async_resume( void *config_data_arg,
break; break;
} }
if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_PK ) if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_RESUME )
{ {
mbedtls_printf( "Async resume callback: %s done but injected error\n", mbedtls_printf( "Async resume callback: %s done but injected error\n",
op_name ); op_name );

View file

@ -4246,17 +4246,6 @@ run_test "SSL async private: error in resume" \
"$P_CLI" \ "$P_CLI" \
1 \ 1 \
-s "Async sign callback: using key slot " \ -s "Async sign callback: using key slot " \
-s "Async resume callback: injected error" \
-s "! mbedtls_ssl_handshake returned"
requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE
run_test "SSL async private: error in pk" \
"$P_SRV \
async_operations=s async_private_delay1=1 async_private_delay2=1 \
async_private_error=4" \
"$P_CLI" \
1 \
-s "Async sign callback: using key slot " \
-s "Async resume callback: sign done but injected error" \ -s "Async resume callback: sign done but injected error" \
-s "! mbedtls_ssl_handshake returned" -s "! mbedtls_ssl_handshake returned"