Add build version to the output of ssl_client2

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
Yanray Wang 2022-10-17 15:13:30 +08:00
parent 47da7bfac8
commit d976673dd6

View file

@ -25,6 +25,10 @@
#include "test/psa_crypto_helpers.h" #include "test/psa_crypto_helpers.h"
#endif /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */ #endif /* MBEDTLS_USE_PSA_CRYPTO || MBEDTLS_SSL_PROTO_TLS1_3 */
#if defined(MBEDTLS_VERSION_C)
#include "mbedtls/build_info.h"
#endif /* MBEDTLS_VERSION_C */
#if defined(MBEDTLS_SSL_TEST_IMPOSSIBLE) #if defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
int main( void ) int main( void )
{ {
@ -360,6 +364,14 @@ int main( void )
#define USAGE_TLS1_3_KEY_EXCHANGE_MODES "" #define USAGE_TLS1_3_KEY_EXCHANGE_MODES ""
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
#if defined(MBEDTLS_VERSION_C)
#define USAGE_BUILD_VERSION \
" build_version=%%d default: none (disabled)\n" \
" option: 1 (print the build version only a stop)\n"
#else
#define USAGE_BUILD_VERSION ""
#endif /* MBEDTLS_VERSION_C */
/* USAGE is arbitrarily split to stay under the portable string literal /* USAGE is arbitrarily split to stay under the portable string literal
* length limit: 4095 bytes in C99. */ * length limit: 4095 bytes in C99. */
#define USAGE1 \ #define USAGE1 \
@ -375,6 +387,7 @@ int main( void )
" application data message is sent followed by\n" \ " application data message is sent followed by\n" \
" a second non-empty message before attempting\n" \ " a second non-empty message before attempting\n" \
" to read a response from the server\n" \ " to read a response from the server\n" \
USAGE_BUILD_VERSION \
" debug_level=%%d default: 0 (disabled)\n" \ " debug_level=%%d default: 0 (disabled)\n" \
" nbio=%%d default: 0 (blocking I/O)\n" \ " nbio=%%d default: 0 (blocking I/O)\n" \
" options: 1 (non-blocking), 2 (added delays)\n" \ " options: 1 (non-blocking), 2 (added delays)\n" \
@ -984,6 +997,18 @@ int main( int argc, char *argv[] )
if( opt.debug_level < 0 || opt.debug_level > 65535 ) if( opt.debug_level < 0 || opt.debug_level > 65535 )
goto usage; goto usage;
} }
#if defined(MBEDTLS_VERSION_C)
else if( strcmp( p, "build_version" ) == 0 )
{
if( strcmp( q, "1" ) == 0 )
{
mbedtls_printf( "build version: %s (build %u)\n",
MBEDTLS_VERSION_STRING,
MBEDTLS_VERSION_NUMBER );
goto exit;
}
}
#endif /* MBEDTLS_VERSION_C */
else if( strcmp( p, "context_crt_cb" ) == 0 ) else if( strcmp( p, "context_crt_cb" ) == 0 )
{ {
opt.context_crt_cb = atoi( q ); opt.context_crt_cb = atoi( q );
@ -2454,6 +2479,11 @@ int main( int argc, char *argv[] )
} }
} }
#if defined(MBEDTLS_VERSION_C)
mbedtls_printf( "build version: %s (build %u)\n",
MBEDTLS_VERSION_STRING, MBEDTLS_VERSION_NUMBER );
#endif /* MBEDTLS_VERSION_C */
#if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_X509_CRT_PARSE_C)
/* /*
* 5. Verify the server certificate * 5. Verify the server certificate