From c912572a7f6886fc3e28723ca5f2644f3e76a878 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 26 Apr 2018 07:15:40 +0200 Subject: [PATCH] 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. --- programs/ssl/ssl_server2.c | 13 +++---------- tests/ssl-opt.sh | 11 ----------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 28d9e6f4c..544ff3606 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -207,7 +207,7 @@ int main( void ) " async_private_delay2=%%d Asynchronous delay for key_file2\n" \ " default: -1 (not asynchronous)\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 #define USAGE_SSL_ASYNC "" #endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ @@ -875,8 +875,7 @@ typedef enum { SSL_ASYNC_INJECT_ERROR_START, /*!< Inject error during 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_PK /*!< Inject error during resume */ -#define SSL_ASYNC_INJECT_ERROR_MAX SSL_ASYNC_INJECT_ERROR_PK +#define SSL_ASYNC_INJECT_ERROR_MAX SSL_ASYNC_INJECT_ERROR_RESUME } ssl_async_inject_error_t; typedef struct @@ -1019,12 +1018,6 @@ static int ssl_async_resume( void *config_data_arg, int ret; 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 ) { --ctx->remaining_delay; @@ -1057,7 +1050,7 @@ static int ssl_async_resume( void *config_data_arg, 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", op_name ); diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 0f8af026a..6261225b2 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -4246,17 +4246,6 @@ run_test "SSL async private: error in resume" \ "$P_CLI" \ 1 \ -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 "! mbedtls_ssl_handshake returned"