From 7601686acb42fea04c7055f41cd1776dfe9df30f Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Tue, 3 Apr 2018 08:26:29 -0400 Subject: [PATCH] ssl: add pre-verify callback setter test with no callback set --- tests/suites/test_suite_ssl.data | 5 ++++- tests/suites/test_suite_ssl.function | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/suites/test_suite_ssl.data b/tests/suites/test_suite_ssl.data index ec54c73ff..891dc1715 100644 --- a/tests/suites/test_suite_ssl.data +++ b/tests/suites/test_suite_ssl.data @@ -59,4 +59,7 @@ SSL SET_HOSTNAME memory leak: call ssl_set_hostname twice ssl_set_hostname_twice:"server0":"server1" SSL preverify callback: basic -ssl_preverifycb:"data_files/server1.crt" +ssl_preverifycb:"data_files/server1.crt":1:1 + +SSL preverify callback: no callback +ssl_preverifycb:"data_files/server1.crt":0:0 diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index c85846769..573d854d5 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -83,7 +83,7 @@ void ssl_set_hostname_twice( char *hostname0, char *hostname1 ) /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_KEY_EXCHANGE_RSA_ENABLED:MBEDTLS_AES_C:MBEDTLS_SHA256_C:MBEDTLS_CIPHER_MODE_CBC */ -void ssl_preverifycb( char *crt_file ) +void ssl_preverifycb( char *crt_file, int set_callback, int data_value ) { mbedtls_ssl_context ssl; mbedtls_ssl_config conf; @@ -112,10 +112,13 @@ void ssl_preverifycb( char *crt_file ) /* Read in the certificate record, and check it calls the pre-verify callback */ conf.endpoint = MBEDTLS_SSL_IS_CLIENT; - mbedtls_ssl_conf_pre_verify( &conf, pre_vrfy_fn, (void*)&pre_vrfy_data ); + if( set_callback != 0 ) + { + mbedtls_ssl_conf_pre_verify( &conf, pre_vrfy_fn, (void*)&pre_vrfy_data ); + } TEST_ASSERT( mbedtls_ssl_parse_certificate( &ssl ) == 0 ); - TEST_ASSERT( pre_vrfy_data != 0 ); + TEST_ASSERT( pre_vrfy_data == data_value ); mbedtls_ssl_free( &ssl ); mbedtls_ssl_config_free( &conf );