ssl_test_lib: move initial includes and is-it-supported check
Move from ssl_*2.c to ssl_test_lib.h: * The inclusion of the config header file (identical). * The fallback definitions of platform functions (almost identical: server2 also had snprintf and the order and whitespace was slightly different). * The compilation guards checking that required options are enabled (tweaked to make them common, with MBEDTLS_SSL_{CLI,SRV}_C separated out). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
0d980b8be8
commit
ab7ce96d7b
4 changed files with 59 additions and 60 deletions
|
@ -17,39 +17,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
#include "ssl_test_lib.h"
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_exit exit
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||
#if defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf( "MBEDTLS_ENTROPY_C and/or "
|
||||
"MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined "
|
||||
" and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined.\n" );
|
||||
mbedtls_printf( MBEDTLS_SSL_TEST_IMPOSSIBLE );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#elif !defined(MBEDTLS_SSL_CLI_C)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf( "MBEDTLS_SSL_CLI_C not defined.\n" );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -17,39 +17,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
#include "ssl_test_lib.h"
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_exit exit
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_SRV_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||
#if defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf( "MBEDTLS_ENTROPY_C and/or "
|
||||
"MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined "
|
||||
" and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined.\n" );
|
||||
mbedtls_printf( MBEDTLS_SSL_TEST_IMPOSSIBLE );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#elif !defined(MBEDTLS_SSL_SRV_C)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf( "MBEDTLS_SSL_SRV_C not defined.\n" );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -22,3 +22,6 @@
|
|||
|
||||
#include "ssl_test_lib.h"
|
||||
|
||||
#if !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
||||
|
||||
#endif /* !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE) */
|
||||
|
|
|
@ -20,4 +20,42 @@
|
|||
#ifndef MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H
|
||||
#define MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_exit exit
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || \
|
||||
defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
|
||||
#define MBEDTLS_SSL_TEST_IMPOSSIBLE \
|
||||
"MBEDTLS_CTR_DRBG_C and/or " \
|
||||
"MBEDTLS_ENTROPY_C and/or " \
|
||||
"MBEDTLS_NET_C and/or " \
|
||||
"MBEDTLS_SSL_TLS_C not defined, " \
|
||||
"and/or MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER defined.\n"
|
||||
#else
|
||||
#undef MBEDTLS_SSL_TEST_IMPOSSIBLE
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H */
|
||||
|
|
Loading…
Reference in a new issue