mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Applying current changes
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
This commit is contained in:
@ -1,17 +1,16 @@
|
||||
|
||||
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
|
||||
# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
|
||||
|
||||
CFLAGS ?= -O2
|
||||
WARNING_CFLAGS ?= -Wall -Wextra
|
||||
WARNING_CXXFLAGS ?= -Wall -Wextra
|
||||
WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
|
||||
WARNING_CXXFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
|
||||
LDFLAGS ?=
|
||||
|
||||
MBEDTLS_TEST_PATH:=../tests/src
|
||||
MBEDTLS_TEST_OBJS:=$(patsubst %.c,%.o,$(wildcard ${MBEDTLS_TEST_PATH}/*.c ${MBEDTLS_TEST_PATH}/drivers/*.c))
|
||||
|
||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../tests/include -I../include -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -I../tests/include -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \
|
||||
-L../library \
|
||||
-lmbedtls$(SHARED_SUFFIX) \
|
||||
@ -50,11 +49,6 @@ EXEXT=
|
||||
SHARED_SUFFIX=
|
||||
endif
|
||||
|
||||
# Zlib shared library extensions:
|
||||
ifdef ZLIB
|
||||
LOCAL_LDFLAGS += -lz
|
||||
endif
|
||||
|
||||
APPS = \
|
||||
aes/aescrypt2$(EXEXT) \
|
||||
aes/crypt_and_hash$(EXEXT) \
|
||||
@ -238,7 +232,7 @@ psa/key_ladder_demo$(EXEXT): psa/key_ladder_demo.c $(DEP)
|
||||
echo " CC psa/key_ladder_demo.c"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/key_ladder_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
psa/psa_constant_names$(EXEXT): psa/psa_constant_names.c $(DEP)
|
||||
psa/psa_constant_names$(EXEXT): psa/psa_constant_names.c psa/psa_constant_names_generated.c $(DEP)
|
||||
echo " CC psa/psa_constant_names.c"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/psa_constant_names.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
|
@ -2,14 +2,6 @@ set(libs
|
||||
${mbedtls_target}
|
||||
)
|
||||
|
||||
if(USE_PKCS11_HELPER_LIBRARY)
|
||||
set(libs ${libs} pkcs11-helper)
|
||||
endif(USE_PKCS11_HELPER_LIBRARY)
|
||||
|
||||
if(ENABLE_ZLIB_SUPPORT)
|
||||
set(libs ${libs} ${ZLIB_LIBRARIES})
|
||||
endif(ENABLE_ZLIB_SUPPORT)
|
||||
|
||||
find_library(FUZZINGENGINE_LIB FuzzingEngine)
|
||||
if(FUZZINGENGINE_LIB)
|
||||
project(fuzz CXX)
|
||||
@ -44,6 +36,7 @@ foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
|
||||
endif()
|
||||
|
||||
add_executable(${exe} ${exe_sources})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
|
||||
if (NOT FUZZINGENGINE_LIB)
|
||||
target_link_libraries(${exe} ${libs})
|
||||
|
@ -23,11 +23,6 @@ SHARED_SUFFIX=
|
||||
# python2 for POSIX since FreeBSD has only python2 as default.
|
||||
PYTHON ?= python2
|
||||
|
||||
# Zlib shared library extensions:
|
||||
ifdef ZLIB
|
||||
LOCAL_LDFLAGS += -lz
|
||||
endif
|
||||
|
||||
ifdef FUZZINGENGINE
|
||||
LOCAL_LDFLAGS += -lFuzzingEngine
|
||||
endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "test/certs.h"
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -6,9 +6,8 @@
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/timing.h"
|
||||
|
||||
#include "test/certs.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_CLI_C) && \
|
||||
defined(MBEDTLS_ENTROPY_C) && \
|
||||
|
@ -3,10 +3,10 @@
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "test/certs.h"
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/timing.h"
|
||||
#include "mbedtls/ssl_cookie.h"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/ssl_ticket.h"
|
||||
#include "test/certs.h"
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -159,7 +159,7 @@ static psa_status_t
|
||||
cipher_example_encrypt_decrypt_aes_cbc_nopad_1_block( void )
|
||||
{
|
||||
enum {
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ),
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_LENGTH( PSA_KEY_TYPE_AES ),
|
||||
key_bits = 256,
|
||||
part_size = block_size,
|
||||
};
|
||||
@ -207,7 +207,7 @@ exit:
|
||||
static psa_status_t cipher_example_encrypt_decrypt_aes_cbc_pkcs7_multi( void )
|
||||
{
|
||||
enum {
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ),
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_LENGTH( PSA_KEY_TYPE_AES ),
|
||||
key_bits = 256,
|
||||
input_size = 100,
|
||||
part_size = 10,
|
||||
@ -255,7 +255,7 @@ exit:
|
||||
static psa_status_t cipher_example_encrypt_decrypt_aes_ctr_multi( void )
|
||||
{
|
||||
enum {
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ),
|
||||
block_size = PSA_BLOCK_CIPHER_BLOCK_LENGTH( PSA_KEY_TYPE_AES ),
|
||||
key_bits = 256,
|
||||
input_size = 100,
|
||||
part_size = 10,
|
||||
|
@ -8,6 +8,8 @@ static const char *psa_strerror(psa_status_t status)
|
||||
case PSA_ERROR_BUFFER_TOO_SMALL: return "PSA_ERROR_BUFFER_TOO_SMALL";
|
||||
case PSA_ERROR_COMMUNICATION_FAILURE: return "PSA_ERROR_COMMUNICATION_FAILURE";
|
||||
case PSA_ERROR_CORRUPTION_DETECTED: return "PSA_ERROR_CORRUPTION_DETECTED";
|
||||
case PSA_ERROR_DATA_CORRUPT: return "PSA_ERROR_DATA_CORRUPT";
|
||||
case PSA_ERROR_DATA_INVALID: return "PSA_ERROR_DATA_INVALID";
|
||||
case PSA_ERROR_DOES_NOT_EXIST: return "PSA_ERROR_DOES_NOT_EXIST";
|
||||
case PSA_ERROR_GENERIC_ERROR: return "PSA_ERROR_GENERIC_ERROR";
|
||||
case PSA_ERROR_HARDWARE_FAILURE: return "PSA_ERROR_HARDWARE_FAILURE";
|
||||
@ -38,6 +40,7 @@ static const char *psa_ecc_family_name(psa_ecc_family_t curve)
|
||||
case PSA_ECC_FAMILY_SECT_K1: return "PSA_ECC_FAMILY_SECT_K1";
|
||||
case PSA_ECC_FAMILY_SECT_R1: return "PSA_ECC_FAMILY_SECT_R1";
|
||||
case PSA_ECC_FAMILY_SECT_R2: return "PSA_ECC_FAMILY_SECT_R2";
|
||||
case PSA_ECC_FAMILY_TWISTED_EDWARDS: return "PSA_ECC_FAMILY_TWISTED_EDWARDS";
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
@ -64,6 +67,7 @@ static const char *psa_hash_algorithm_name(psa_algorithm_t hash_alg)
|
||||
case PSA_ALG_SHA3_256: return "PSA_ALG_SHA3_256";
|
||||
case PSA_ALG_SHA3_384: return "PSA_ALG_SHA3_384";
|
||||
case PSA_ALG_SHA3_512: return "PSA_ALG_SHA3_512";
|
||||
case PSA_ALG_SHAKE256_512: return "PSA_ALG_SHAKE256_512";
|
||||
case PSA_ALG_SHA_1: return "PSA_ALG_SHA_1";
|
||||
case PSA_ALG_SHA_224: return "PSA_ALG_SHA_224";
|
||||
case PSA_ALG_SHA_256: return "PSA_ALG_SHA_256";
|
||||
@ -148,19 +152,27 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||
unsigned long length_modifier = NO_LENGTH_MODIFIER;
|
||||
if (PSA_ALG_IS_MAC(alg)) {
|
||||
core_alg = PSA_ALG_TRUNCATED_MAC(alg, 0);
|
||||
if (core_alg != alg) {
|
||||
if (alg & PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG) {
|
||||
append(&buffer, buffer_size, &required_size,
|
||||
"PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(", 33);
|
||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||
} else if (core_alg != alg) {
|
||||
append(&buffer, buffer_size, &required_size,
|
||||
"PSA_ALG_TRUNCATED_MAC(", 22);
|
||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||
}
|
||||
} else if (PSA_ALG_IS_AEAD(alg)) {
|
||||
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg);
|
||||
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(alg);
|
||||
if (core_alg == 0) {
|
||||
/* For unknown AEAD algorithms, there is no "default tag length". */
|
||||
core_alg = alg;
|
||||
} else if (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) {
|
||||
append(&buffer, buffer_size, &required_size,
|
||||
"PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(", 43);
|
||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||
} else if (core_alg != alg) {
|
||||
append(&buffer, buffer_size, &required_size,
|
||||
"PSA_ALG_AEAD_WITH_TAG_LENGTH(", 29);
|
||||
"PSA_ALG_AEAD_WITH_SHORTENED_TAG(", 32);
|
||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||
}
|
||||
} else if (PSA_ALG_IS_KEY_AGREEMENT(alg) &&
|
||||
@ -198,14 +210,18 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||
case PSA_ALG_ECB_NO_PADDING: append(&buffer, buffer_size, &required_size, "PSA_ALG_ECB_NO_PADDING", 22); break;
|
||||
case PSA_ALG_ECDH: append(&buffer, buffer_size, &required_size, "PSA_ALG_ECDH", 12); break;
|
||||
case PSA_ALG_ECDSA_ANY: append(&buffer, buffer_size, &required_size, "PSA_ALG_ECDSA_ANY", 17); break;
|
||||
case PSA_ALG_ED25519PH: append(&buffer, buffer_size, &required_size, "PSA_ALG_ED25519PH", 17); break;
|
||||
case PSA_ALG_ED448PH: append(&buffer, buffer_size, &required_size, "PSA_ALG_ED448PH", 15); break;
|
||||
case PSA_ALG_FFDH: append(&buffer, buffer_size, &required_size, "PSA_ALG_FFDH", 12); break;
|
||||
case PSA_ALG_GCM: append(&buffer, buffer_size, &required_size, "PSA_ALG_GCM", 11); break;
|
||||
case PSA_ALG_HASH_EDDSA_BASE: append(&buffer, buffer_size, &required_size, "PSA_ALG_HASH_EDDSA_BASE", 23); break;
|
||||
case PSA_ALG_HKDF_BASE: append(&buffer, buffer_size, &required_size, "PSA_ALG_HKDF_BASE", 17); break;
|
||||
case PSA_ALG_HMAC_BASE: append(&buffer, buffer_size, &required_size, "PSA_ALG_HMAC_BASE", 17); break;
|
||||
case PSA_ALG_MD2: append(&buffer, buffer_size, &required_size, "PSA_ALG_MD2", 11); break;
|
||||
case PSA_ALG_MD4: append(&buffer, buffer_size, &required_size, "PSA_ALG_MD4", 11); break;
|
||||
case PSA_ALG_MD5: append(&buffer, buffer_size, &required_size, "PSA_ALG_MD5", 11); break;
|
||||
case PSA_ALG_OFB: append(&buffer, buffer_size, &required_size, "PSA_ALG_OFB", 11); break;
|
||||
case PSA_ALG_PURE_EDDSA: append(&buffer, buffer_size, &required_size, "PSA_ALG_PURE_EDDSA", 18); break;
|
||||
case PSA_ALG_RIPEMD160: append(&buffer, buffer_size, &required_size, "PSA_ALG_RIPEMD160", 17); break;
|
||||
case PSA_ALG_RSA_OAEP_BASE: append(&buffer, buffer_size, &required_size, "PSA_ALG_RSA_OAEP_BASE", 21); break;
|
||||
case PSA_ALG_RSA_PKCS1V15_CRYPT: append(&buffer, buffer_size, &required_size, "PSA_ALG_RSA_PKCS1V15_CRYPT", 26); break;
|
||||
@ -215,6 +231,7 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||
case PSA_ALG_SHA3_256: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA3_256", 16); break;
|
||||
case PSA_ALG_SHA3_384: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA3_384", 16); break;
|
||||
case PSA_ALG_SHA3_512: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA3_512", 16); break;
|
||||
case PSA_ALG_SHAKE256_512: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHAKE256_512", 20); break;
|
||||
case PSA_ALG_SHA_1: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA_1", 13); break;
|
||||
case PSA_ALG_SHA_224: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA_224", 15); break;
|
||||
case PSA_ALG_SHA_256: append(&buffer, buffer_size, &required_size, "PSA_ALG_SHA_256", 15); break;
|
||||
|
@ -5,14 +5,6 @@ set(libs
|
||||
${mbedtls_target}
|
||||
)
|
||||
|
||||
if(USE_PKCS11_HELPER_LIBRARY)
|
||||
set(libs ${libs} pkcs11-helper)
|
||||
endif(USE_PKCS11_HELPER_LIBRARY)
|
||||
|
||||
if(ENABLE_ZLIB_SUPPORT)
|
||||
set(libs ${libs} ${ZLIB_LIBRARIES})
|
||||
endif(ENABLE_ZLIB_SUPPORT)
|
||||
|
||||
set(executables
|
||||
dtls_client
|
||||
dtls_server
|
||||
@ -45,6 +37,7 @@ set_property(TARGET ssl_server2 APPEND PROPERTY SOURCES
|
||||
|
||||
if(THREADS_FOUND)
|
||||
add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
|
||||
target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
list(APPEND executables ssl_pthread_server)
|
||||
endif(THREADS_FOUND)
|
||||
|
@ -39,14 +39,14 @@
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_TIMING_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C)
|
||||
!defined(MBEDTLS_PEM_PARSE_C)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf( "MBEDTLS_SSL_CLI_C and/or MBEDTLS_SSL_PROTO_DTLS and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_TIMING_C and/or "
|
||||
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or "
|
||||
"MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or "
|
||||
"MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.\n" );
|
||||
"MBEDTLS_PEM_PARSE_C not defined.\n" );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#else
|
||||
@ -59,8 +59,8 @@ int main( void )
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/timing.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
/* Uncomment out the following line to default to IPv4 and disable IPv6 */
|
||||
//#define FORCE_IPV4
|
||||
@ -191,6 +191,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
|
||||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
|
||||
mbedtls_ssl_conf_read_timeout( &conf, READ_TIMEOUT_MS );
|
||||
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
|
||||
{
|
||||
@ -358,5 +359,4 @@ exit:
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_PROTO_DTLS && MBEDTLS_NET_C &&
|
||||
MBEDTLD_TIMING_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C &&
|
||||
MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_RSA_C && MBEDTLS_CERTS_C &&
|
||||
MBEDTLS_PEM_PARSE_C */
|
||||
MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_RSA_C && MBEDTLS_PEM_PARSE_C */
|
||||
|
@ -49,8 +49,7 @@
|
||||
!defined(MBEDTLS_SSL_COOKIE_C) || !defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \
|
||||
!defined(MBEDTLS_TIMING_C)
|
||||
!defined(MBEDTLS_PEM_PARSE_C) || !defined(MBEDTLS_TIMING_C)
|
||||
|
||||
int main( void )
|
||||
{
|
||||
@ -58,8 +57,7 @@ int main( void )
|
||||
"MBEDTLS_SSL_COOKIE_C and/or MBEDTLS_NET_C and/or "
|
||||
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or "
|
||||
"MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or "
|
||||
"MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C and/or "
|
||||
"MBEDTLS_TIMING_C not defined.\n" );
|
||||
"MBEDTLS_PEM_PARSE_C and/or MBEDTLS_TIMING_C not defined.\n" );
|
||||
mbedtls_exit( 0 );
|
||||
}
|
||||
#else
|
||||
@ -74,7 +72,6 @@ int main( void )
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/ssl_cookie.h"
|
||||
@ -82,12 +79,13 @@ int main( void )
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls/timing.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
#include "mbedtls/ssl_cache.h"
|
||||
#endif
|
||||
|
||||
#define READ_TIMEOUT_MS 10000 /* 5 seconds */
|
||||
#define READ_TIMEOUT_MS 10000 /* 10 seconds */
|
||||
#define DEBUG_LEVEL 0
|
||||
|
||||
|
||||
@ -223,6 +221,7 @@ int main( void )
|
||||
|
||||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
|
||||
mbedtls_ssl_conf_read_timeout( &conf, READ_TIMEOUT_MS );
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
mbedtls_ssl_conf_session_cache( &conf, &cache,
|
||||
@ -434,4 +433,4 @@ exit:
|
||||
#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_PROTO_DTLS &&
|
||||
MBEDTLS_SSL_COOKIE_C && MBEDTLS_NET_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_CTR_DRBG_C && MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_RSA_C
|
||||
&& MBEDTLS_CERTS_C && MBEDTLS_PEM_PARSE_C && MBEDTLS_TIMING_C */
|
||||
&& MBEDTLS_PEM_PARSE_C && MBEDTLS_TIMING_C */
|
||||
|
@ -37,11 +37,11 @@
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C) || \
|
||||
!defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_CLI_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_PEM_PARSE_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or "
|
||||
@ -59,7 +59,7 @@ int main( void )
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -314,5 +314,4 @@ exit:
|
||||
}
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
|
||||
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&
|
||||
MBEDTLS_CERTS_C && MBEDTLS_PEM_PARSE_C && MBEDTLS_CTR_DRBG_C &&
|
||||
MBEDTLS_X509_CRT_PARSE_C */
|
||||
MBEDTLS_PEM_PARSE_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
@ -69,7 +69,6 @@ int main( void )
|
||||
#define DFL_EXCHANGES 1
|
||||
#define DFL_MIN_VERSION -1
|
||||
#define DFL_MAX_VERSION -1
|
||||
#define DFL_ARC4 -1
|
||||
#define DFL_SHA1 -1
|
||||
#define DFL_AUTH_MODE -1
|
||||
#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE
|
||||
@ -419,12 +418,11 @@ int main( void )
|
||||
USAGE_DHMLEN \
|
||||
"\n"
|
||||
#define USAGE4 \
|
||||
" arc4=%%d default: (library default: 0)\n" \
|
||||
" allow_sha1=%%d default: 0\n" \
|
||||
" min_version=%%s default: (library default: tls1)\n" \
|
||||
" max_version=%%s default: (library default: tls1_2)\n" \
|
||||
" force_version=%%s default: \"\" (none)\n" \
|
||||
" options: ssl3, tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \
|
||||
" options: tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \
|
||||
"\n" \
|
||||
" force_ciphersuite=<name> default: all enabled\n"\
|
||||
" query_config=<name> return 0 if the specified\n" \
|
||||
@ -477,7 +475,6 @@ struct options
|
||||
int exchanges; /* number of data exchanges */
|
||||
int min_version; /* minimum protocol version accepted */
|
||||
int max_version; /* maximum protocol version accepted */
|
||||
int arc4; /* flag for arc4 suites support */
|
||||
int allow_sha1; /* flag for SHA-1 support */
|
||||
int auth_mode; /* verify mode for connection */
|
||||
unsigned char mfl_code; /* code for maximum fragment length */
|
||||
@ -686,8 +683,7 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
|
||||
#endif
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
rng_context_t rng;
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_config conf;
|
||||
mbedtls_ssl_session saved_session;
|
||||
@ -704,7 +700,7 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_key_id_t key_slot = 0; /* invalid key slot */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
char *p, *q;
|
||||
const int *list;
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
@ -735,6 +731,10 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
test_hooks_init( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
/*
|
||||
* Make sure memory references are valid.
|
||||
*/
|
||||
@ -742,7 +742,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ssl_config_init( &conf );
|
||||
memset( &saved_session, 0, sizeof( mbedtls_ssl_session ) );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
rng_init( &rng );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
@ -761,7 +761,10 @@ int main( int argc, char *argv[] )
|
||||
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
|
||||
if( argc == 0 )
|
||||
{
|
||||
@ -826,7 +829,6 @@ int main( int argc, char *argv[] )
|
||||
opt.exchanges = DFL_EXCHANGES;
|
||||
opt.min_version = DFL_MIN_VERSION;
|
||||
opt.max_version = DFL_MAX_VERSION;
|
||||
opt.arc4 = DFL_ARC4;
|
||||
opt.allow_sha1 = DFL_SHA1;
|
||||
opt.auth_mode = DFL_AUTH_MODE;
|
||||
opt.mfl_code = DFL_MFL_CODE;
|
||||
@ -1090,9 +1092,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "min_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
else if( strcmp( q, "tls1_1" ) == 0 ||
|
||||
strcmp( q, "dtls1" ) == 0 )
|
||||
@ -1105,9 +1105,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "max_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
else if( strcmp( q, "tls1_1" ) == 0 ||
|
||||
strcmp( q, "dtls1" ) == 0 )
|
||||
@ -1118,15 +1116,6 @@ int main( int argc, char *argv[] )
|
||||
else
|
||||
goto usage;
|
||||
}
|
||||
else if( strcmp( p, "arc4" ) == 0 )
|
||||
{
|
||||
switch( atoi( q ) )
|
||||
{
|
||||
case 0: opt.arc4 = MBEDTLS_SSL_ARC4_DISABLED; break;
|
||||
case 1: opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; break;
|
||||
default: goto usage;
|
||||
}
|
||||
}
|
||||
else if( strcmp( p, "allow_sha1" ) == 0 )
|
||||
{
|
||||
switch( atoi( q ) )
|
||||
@ -1138,12 +1127,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "force_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
{
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
}
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
{
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
@ -1391,19 +1375,6 @@ int main( int argc, char *argv[] )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2;
|
||||
}
|
||||
|
||||
/* Enable RC4 if needed and not explicitly disabled */
|
||||
if( ciphersuite_info->cipher == MBEDTLS_CIPHER_ARC4_128 )
|
||||
{
|
||||
if( opt.arc4 == MBEDTLS_SSL_ARC4_DISABLED )
|
||||
{
|
||||
mbedtls_printf( "forced RC4 ciphersuite with RC4 disabled\n" );
|
||||
ret = 2;
|
||||
goto usage;
|
||||
}
|
||||
|
||||
opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( opt.psk_opaque != 0 )
|
||||
{
|
||||
@ -1534,31 +1505,9 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if (opt.reproducible)
|
||||
{
|
||||
srand( 1 );
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
ret = rng_seed( &rng, opt.reproducible, pers );
|
||||
if( ret != 0 )
|
||||
goto exit;
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
@ -1581,7 +1530,6 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
{
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
|
||||
@ -1603,12 +1551,6 @@ int main( int argc, char *argv[] )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
if( ret < 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
|
||||
@ -1634,16 +1576,9 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
ret = mbedtls_x509_crt_parse( &clicert,
|
||||
(const unsigned char *) mbedtls_test_cli_crt,
|
||||
mbedtls_test_cli_crt_len );
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
|
||||
@ -1659,16 +1594,9 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, opt.key_pwd );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
ret = mbedtls_pk_parse_key( &pkey,
|
||||
(const unsigned char *) mbedtls_test_cli_key,
|
||||
mbedtls_test_cli_key_len, NULL, 0 );
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
|
||||
@ -1683,7 +1611,7 @@ int main( int argc, char *argv[] )
|
||||
PSA_ALG_SHA_256 ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! "
|
||||
"mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", -ret );
|
||||
"mbedtls_pk_wrap_as_opaque returned -0x%x\n\n", (unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -1902,9 +1830,9 @@ int main( int argc, char *argv[] )
|
||||
#else
|
||||
fprintf( stderr, "Warning: reproducible option used without constant time\n" );
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
}
|
||||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
mbedtls_ssl_conf_rng( &conf, rng_get, &rng );
|
||||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
|
||||
|
||||
mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout );
|
||||
@ -1916,11 +1844,6 @@ int main( int argc, char *argv[] )
|
||||
if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER )
|
||||
mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite );
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
if( opt.arc4 != DFL_ARC4 )
|
||||
mbedtls_ssl_conf_arc4_support( &conf, opt.arc4 );
|
||||
#endif
|
||||
|
||||
if( opt.allow_legacy != DFL_ALLOW_LEGACY )
|
||||
mbedtls_ssl_conf_legacy_renegotiation( &conf, opt.allow_legacy );
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
@ -1948,7 +1871,7 @@ int main( int argc, char *argv[] )
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
if( opt.curves != NULL &&
|
||||
@ -2152,7 +2075,7 @@ int main( int argc, char *argv[] )
|
||||
if( ( ret = mbedtls_ssl_get_record_expansion( &ssl ) ) >= 0 )
|
||||
mbedtls_printf( " [ Record expansion is %d ]\n", ret );
|
||||
else
|
||||
mbedtls_printf( " [ Record expansion is unknown (compression) ]\n" );
|
||||
mbedtls_printf( " [ Record expansion is unknown ]\n" );
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
mbedtls_printf( " [ Maximum input fragment length is %u ]\n",
|
||||
@ -3020,20 +2943,7 @@ exit:
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
psa_destroy_key( key_slot );
|
||||
#endif
|
||||
#endif
|
||||
mbedtls_ssl_session_free( &saved_session );
|
||||
mbedtls_ssl_free( &ssl );
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
if( session_data != NULL )
|
||||
mbedtls_platform_zeroize( session_data, session_data_len );
|
||||
mbedtls_free( session_data );
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
if( context_buf != NULL )
|
||||
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
||||
mbedtls_free( context_buf );
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) && \
|
||||
defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
@ -3056,12 +2966,39 @@ exit:
|
||||
#endif /* MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED &&
|
||||
MBEDTLS_USE_PSA_CRYPTO */
|
||||
|
||||
mbedtls_ssl_session_free( &saved_session );
|
||||
mbedtls_ssl_free( &ssl );
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
rng_free( &rng );
|
||||
if( session_data != NULL )
|
||||
mbedtls_platform_zeroize( session_data, session_data_len );
|
||||
mbedtls_free( session_data );
|
||||
#if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
|
||||
if( context_buf != NULL )
|
||||
mbedtls_platform_zeroize( context_buf, context_buf_len );
|
||||
mbedtls_free( context_buf );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
mbedtls_psa_crypto_free( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
if( test_hooks_failure_detected( ) )
|
||||
{
|
||||
if( ret == 0 )
|
||||
ret = 1;
|
||||
mbedtls_printf( "Test hooks detected errors.\n" );
|
||||
}
|
||||
test_hooks_free( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_memory_buffer_alloc_status();
|
||||
#endif
|
||||
mbedtls_memory_buffer_alloc_free();
|
||||
#endif
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
|
||||
#if defined(_WIN32)
|
||||
if( opt.query_config_mode == DFL_QUERY_CONFIG_MODE )
|
||||
|
@ -48,7 +48,6 @@ int main( void )
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/base64.h"
|
||||
#include "mbedtls/md.h"
|
||||
#include "mbedtls/md_internal.h"
|
||||
#include "mbedtls/x509_crt.h"
|
||||
#include "mbedtls/ssl_ciphersuites.h"
|
||||
|
||||
@ -638,7 +637,7 @@ void print_deserialized_ssl_session( const uint8_t *ssl, uint32_t len,
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "\tMessage-Digest : %s\n", md_info->name );
|
||||
printf( "\tMessage-Digest : %s\n", mbedtls_md_get_name( md_info ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,18 +36,18 @@
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \
|
||||
!defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_TIMING_C) || \
|
||||
!defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_PEM_PARSE_C)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_SRV_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
|
||||
!defined(MBEDTLS_TIMING_C) || !defined(MBEDTLS_FS_IO) || \
|
||||
!defined(MBEDTLS_PEM_PARSE_C)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
((void) argc);
|
||||
((void) argv);
|
||||
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C "
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C "
|
||||
"and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
|
||||
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or "
|
||||
@ -65,7 +65,7 @@ int main( void )
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "test/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
@ -417,7 +417,7 @@ exit:
|
||||
|
||||
mbedtls_exit( exit_code );
|
||||
}
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C &&
|
||||
MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_PARSE_C &&
|
||||
! _WIN32 */
|
||||
|
@ -65,7 +65,7 @@ int main( void )
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "test/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -509,12 +509,12 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_PEM_PARSE_C)
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
|
||||
mbedtls_test_cas_pem_len );
|
||||
#else
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.");
|
||||
mbedtls_printf("MBEDTLS_PEM_PARSE_C not defined.");
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
@ -539,15 +539,8 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt,
|
||||
mbedtls_test_cli_crt_len );
|
||||
#else
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_CERTS_C not defined.");
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned %d\n\n", ret );
|
||||
@ -559,12 +552,12 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_PEM_PARSE_C)
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_cli_key,
|
||||
mbedtls_test_cli_key_len, NULL, 0 );
|
||||
#else
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_CERTS_C or MBEDTLS_PEM_PARSE_C not defined.");
|
||||
mbedtls_printf("MBEDTLS_PEM_PARSE_C not defined.");
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
|
@ -37,16 +37,15 @@
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \
|
||||
!defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \
|
||||
!defined(MBEDTLS_THREADING_C) || !defined(MBEDTLS_THREADING_PTHREAD) || \
|
||||
!defined(MBEDTLS_PEM_PARSE_C)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_SSL_TLS_C) || !defined(MBEDTLS_SSL_SRV_C) || \
|
||||
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_RSA_C) || \
|
||||
!defined(MBEDTLS_CTR_DRBG_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \
|
||||
!defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_THREADING_C) || \
|
||||
!defined(MBEDTLS_THREADING_PTHREAD) || !defined(MBEDTLS_PEM_PARSE_C)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C "
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C "
|
||||
"and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
|
||||
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or "
|
||||
@ -65,11 +64,11 @@ int main( void )
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
#include "mbedtls/ssl_cache.h"
|
||||
@ -142,7 +141,7 @@ static void *handle_ssl_connection( void *data )
|
||||
if( ( ret = mbedtls_ssl_setup( &ssl, thread_info->config ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_setup returned -0x%04x\n",
|
||||
thread_id, -ret );
|
||||
thread_id, ( unsigned int ) -ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
|
||||
@ -158,7 +157,7 @@ static void *handle_ssl_connection( void *data )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
{
|
||||
mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_handshake returned -0x%04x\n",
|
||||
thread_id, -ret );
|
||||
thread_id, ( unsigned int ) -ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
}
|
||||
@ -195,7 +194,7 @@ static void *handle_ssl_connection( void *data )
|
||||
|
||||
default:
|
||||
mbedtls_printf( " [ #%ld ] mbedtls_ssl_read returned -0x%04x\n",
|
||||
thread_id, -ret );
|
||||
thread_id, ( unsigned int ) -ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
}
|
||||
@ -229,7 +228,7 @@ static void *handle_ssl_connection( void *data )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
{
|
||||
mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_write returned -0x%04x\n",
|
||||
thread_id, ret );
|
||||
thread_id, ( unsigned int ) ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
}
|
||||
@ -246,7 +245,7 @@ static void *handle_ssl_connection( void *data )
|
||||
ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
{
|
||||
mbedtls_printf( " [ #%ld ] failed: mbedtls_ssl_close_notify returned -0x%04x\n",
|
||||
thread_id, ret );
|
||||
thread_id, ( unsigned int ) ret );
|
||||
goto thread_exit;
|
||||
}
|
||||
}
|
||||
@ -263,7 +262,7 @@ thread_exit:
|
||||
char error_buf[100];
|
||||
mbedtls_strerror( ret, error_buf, 100 );
|
||||
mbedtls_printf(" [ #%ld ] Last error was: -0x%04x - %s\n\n",
|
||||
thread_id, -ret, error_buf );
|
||||
thread_id, ( unsigned int ) -ret, error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -408,7 +407,7 @@ int main( void )
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed: mbedtls_ctr_drbg_seed returned -0x%04x\n",
|
||||
-ret );
|
||||
( unsigned int ) -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -425,7 +424,7 @@ int main( void )
|
||||
MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed: mbedtls_ssl_config_defaults returned -0x%04x\n",
|
||||
-ret );
|
||||
( unsigned int ) -ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -470,7 +469,8 @@ reset:
|
||||
{
|
||||
char error_buf[100];
|
||||
mbedtls_strerror( ret, error_buf, 100 );
|
||||
mbedtls_printf( " [ main ] Last error was: -0x%04x - %s\n", -ret, error_buf );
|
||||
mbedtls_printf( " [ main ] Last error was: -0x%04x - %s\n", ( unsigned int ) -ret,
|
||||
error_buf );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -482,7 +482,8 @@ reset:
|
||||
if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd,
|
||||
NULL, 0, NULL ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " [ main ] failed: mbedtls_net_accept returned -0x%04x\n", ret );
|
||||
mbedtls_printf( " [ main ] failed: mbedtls_net_accept returned -0x%04x\n",
|
||||
( unsigned int ) ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@ -525,7 +526,7 @@ exit:
|
||||
mbedtls_exit( ret );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C &&
|
||||
MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_THREADING_C &&
|
||||
MBEDTLS_THREADING_PTHREAD && MBEDTLS_PEM_PARSE_C */
|
||||
|
@ -37,15 +37,14 @@
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \
|
||||
!defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO) || \
|
||||
!defined(MBEDTLS_PEM_PARSE_C)
|
||||
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_PEM_PARSE_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_SSL_TLS_C) || \
|
||||
!defined(MBEDTLS_SSL_SRV_C) || !defined(MBEDTLS_NET_C) || \
|
||||
!defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_FS_IO)
|
||||
int main( void )
|
||||
{
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_CERTS_C and/or MBEDTLS_ENTROPY_C "
|
||||
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C "
|
||||
"and/or MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or "
|
||||
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
|
||||
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
|
||||
@ -63,12 +62,12 @@ int main( void )
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
#include "mbedtls/ssl_cache.h"
|
||||
@ -397,7 +396,7 @@ exit:
|
||||
|
||||
mbedtls_exit( ret );
|
||||
}
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&
|
||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C &&
|
||||
MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C &&
|
||||
MBEDTLS_RSA_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_X509_CRT_PARSE_C
|
||||
&& MBEDTLS_FS_IO && MBEDTLS_PEM_PARSE_C */
|
||||
|
@ -102,7 +102,6 @@ int main( void )
|
||||
#define DFL_EXCHANGES 1
|
||||
#define DFL_MIN_VERSION -1
|
||||
#define DFL_MAX_VERSION -1
|
||||
#define DFL_ARC4 -1
|
||||
#define DFL_SHA1 -1
|
||||
#define DFL_CID_ENABLED 0
|
||||
#define DFL_CID_VALUE ""
|
||||
@ -500,15 +499,14 @@ int main( void )
|
||||
#define USAGE4 \
|
||||
USAGE_SSL_ASYNC \
|
||||
USAGE_SNI \
|
||||
" arc4=%%d default: (library default: 0)\n" \
|
||||
" allow_sha1=%%d default: 0\n" \
|
||||
" min_version=%%s default: (library default: tls1)\n" \
|
||||
" max_version=%%s default: (library default: tls1_2)\n" \
|
||||
" force_version=%%s default: \"\" (none)\n" \
|
||||
" options: ssl3, tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \
|
||||
" options: tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \
|
||||
"\n" \
|
||||
" version_suites=a,b,c,d per-version ciphersuites\n" \
|
||||
" in order from ssl3 to tls1_2\n" \
|
||||
" version_suites=a,b,c per-version ciphersuites\n" \
|
||||
" in order from tls1 to tls1_2\n" \
|
||||
" default: all enabled\n" \
|
||||
" force_ciphersuite=<name> default: all enabled\n" \
|
||||
" query_config=<name> return 0 if the specified\n" \
|
||||
@ -580,7 +578,6 @@ struct options
|
||||
int exchanges; /* number of data exchanges */
|
||||
int min_version; /* minimum protocol version accepted */
|
||||
int max_version; /* maximum protocol version accepted */
|
||||
int arc4; /* flag for arc4 suites support */
|
||||
int allow_sha1; /* flag for SHA-1 support */
|
||||
int auth_mode; /* verify mode for connection */
|
||||
int cert_req_ca_list; /* should we send the CA list? */
|
||||
@ -1260,7 +1257,7 @@ int main( int argc, char *argv[] )
|
||||
{
|
||||
int ret = 0, len, written, frags, exchanges_left;
|
||||
int query_config_ret = 0;
|
||||
int version_suites[4][2];
|
||||
int version_suites[3][2];
|
||||
io_ctx_t io_ctx;
|
||||
unsigned char* buf = 0;
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
|
||||
@ -1282,8 +1279,7 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
|
||||
#endif
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
rng_context_t rng;
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_config conf;
|
||||
#if defined(MBEDTLS_TIMING_C)
|
||||
@ -1370,6 +1366,10 @@ int main( int argc, char *argv[] )
|
||||
#endif /* MBEDTLS_MEMORY_DEBUG */
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
test_hooks_init( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
/*
|
||||
* Make sure memory references are valid in case we exit early.
|
||||
*/
|
||||
@ -1377,7 +1377,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_net_init( &listen_fd );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ssl_config_init( &conf );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
rng_init( &rng );
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &srvcert );
|
||||
@ -1413,7 +1413,10 @@ int main( int argc, char *argv[] )
|
||||
ret = MBEDTLS_ERR_SSL_HW_ACCEL_FAILED;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
mbedtls_test_enable_insecure_external_rng( );
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* Abort cleanly on SIGTERM and SIGINT */
|
||||
@ -1491,7 +1494,6 @@ int main( int argc, char *argv[] )
|
||||
opt.exchanges = DFL_EXCHANGES;
|
||||
opt.min_version = DFL_MIN_VERSION;
|
||||
opt.max_version = DFL_MAX_VERSION;
|
||||
opt.arc4 = DFL_ARC4;
|
||||
opt.allow_sha1 = DFL_SHA1;
|
||||
opt.auth_mode = DFL_AUTH_MODE;
|
||||
opt.cert_req_ca_list = DFL_CERT_REQ_CA_LIST;
|
||||
@ -1724,9 +1726,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "min_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
else if( strcmp( q, "tls1_1" ) == 0 ||
|
||||
strcmp( q, "dtls1" ) == 0 )
|
||||
@ -1739,9 +1739,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "max_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
else if( strcmp( q, "tls1_1" ) == 0 ||
|
||||
strcmp( q, "dtls1" ) == 0 )
|
||||
@ -1752,15 +1750,6 @@ int main( int argc, char *argv[] )
|
||||
else
|
||||
goto usage;
|
||||
}
|
||||
else if( strcmp( p, "arc4" ) == 0 )
|
||||
{
|
||||
switch( atoi( q ) )
|
||||
{
|
||||
case 0: opt.arc4 = MBEDTLS_SSL_ARC4_DISABLED; break;
|
||||
case 1: opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED; break;
|
||||
default: goto usage;
|
||||
}
|
||||
}
|
||||
else if( strcmp( p, "allow_sha1" ) == 0 )
|
||||
{
|
||||
switch( atoi( q ) )
|
||||
@ -1772,12 +1761,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
else if( strcmp( p, "force_version" ) == 0 )
|
||||
{
|
||||
if( strcmp( q, "ssl3" ) == 0 )
|
||||
{
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_0;
|
||||
}
|
||||
else if( strcmp( q, "tls1" ) == 0 )
|
||||
if( strcmp( q, "tls1" ) == 0 )
|
||||
{
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
opt.max_version = MBEDTLS_SSL_MINOR_VERSION_1;
|
||||
@ -2088,19 +2072,6 @@ int main( int argc, char *argv[] )
|
||||
opt.min_version = MBEDTLS_SSL_MINOR_VERSION_2;
|
||||
}
|
||||
|
||||
/* Enable RC4 if needed and not explicitly disabled */
|
||||
if( ciphersuite_info->cipher == MBEDTLS_CIPHER_ARC4_128 )
|
||||
{
|
||||
if( opt.arc4 == MBEDTLS_SSL_ARC4_DISABLED )
|
||||
{
|
||||
mbedtls_printf("forced RC4 ciphersuite with RC4 disabled\n");
|
||||
ret = 2;
|
||||
goto usage;
|
||||
}
|
||||
|
||||
opt.arc4 = MBEDTLS_SSL_ARC4_ENABLED;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( opt.psk_opaque != 0 || opt.psk_list_opaque != 0 )
|
||||
{
|
||||
@ -2128,11 +2099,11 @@ int main( int argc, char *argv[] )
|
||||
|
||||
if( opt.version_suites != NULL )
|
||||
{
|
||||
const char *name[4] = { 0 };
|
||||
const char *name[3] = { 0 };
|
||||
|
||||
/* Parse 4-element coma-separated list */
|
||||
for( i = 0, p = (char *) opt.version_suites;
|
||||
i < 4 && *p != '\0';
|
||||
i < 3 && *p != '\0';
|
||||
i++ )
|
||||
{
|
||||
name[i] = p;
|
||||
@ -2144,7 +2115,7 @@ int main( int argc, char *argv[] )
|
||||
*p++ = '\0';
|
||||
}
|
||||
|
||||
if( i != 4 )
|
||||
if( i != 3 )
|
||||
{
|
||||
mbedtls_printf( "too few values for version_suites\n" );
|
||||
ret = 1;
|
||||
@ -2154,7 +2125,7 @@ int main( int argc, char *argv[] )
|
||||
memset( version_suites, 0, sizeof( version_suites ) );
|
||||
|
||||
/* Get the suites identifiers from their name */
|
||||
for( i = 0; i < 4; i++ )
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
version_suites[i][0] = mbedtls_ssl_get_ciphersuite_id( name[i] );
|
||||
|
||||
@ -2293,31 +2264,9 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( "\n . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if (opt.reproducible)
|
||||
{
|
||||
srand( 1 );
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, dummy_entropy,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
|
||||
&entropy, (const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
ret = rng_seed( &rng, opt.reproducible, pers );
|
||||
if( ret != 0 )
|
||||
goto exit;
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
@ -2340,7 +2289,6 @@ int main( int argc, char *argv[] )
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
{
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
|
||||
@ -2362,12 +2310,6 @@ int main( int argc, char *argv[] )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
if( ret < 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int) -ret );
|
||||
@ -2443,10 +2385,6 @@ int main( int argc, char *argv[] )
|
||||
strcmp( opt.crt_file2, "none" ) != 0 &&
|
||||
strcmp( opt.key_file2, "none" ) != 0 )
|
||||
{
|
||||
#if !defined(MBEDTLS_CERTS_C)
|
||||
mbedtls_printf( "Not certificated or key provided, and \nMBEDTLS_CERTS_C not defined!\n" );
|
||||
goto exit;
|
||||
#else
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
if( ( ret = mbedtls_x509_crt_parse( &srvcert,
|
||||
(const unsigned char *) mbedtls_test_srv_crt_rsa,
|
||||
@ -2485,7 +2423,6 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
key_cert_init2 = 2;
|
||||
#endif /* MBEDTLS_ECDSA_C */
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
}
|
||||
|
||||
mbedtls_printf( " ok\n" );
|
||||
@ -2704,9 +2641,9 @@ int main( int argc, char *argv[] )
|
||||
#else
|
||||
fprintf( stderr, "Warning: reproducible option used without constant time\n" );
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
}
|
||||
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
|
||||
mbedtls_ssl_conf_rng( &conf, rng_get, &rng );
|
||||
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
@ -2725,7 +2662,7 @@ int main( int argc, char *argv[] )
|
||||
if( opt.tickets == MBEDTLS_SSL_SESSION_TICKETS_ENABLED )
|
||||
{
|
||||
if( ( ret = mbedtls_ssl_ticket_setup( &ticket_ctx,
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg,
|
||||
rng_get, &rng,
|
||||
MBEDTLS_CIPHER_AES_256_GCM,
|
||||
opt.ticket_timeout ) ) != 0 )
|
||||
{
|
||||
@ -2747,7 +2684,7 @@ int main( int argc, char *argv[] )
|
||||
if( opt.cookies > 0 )
|
||||
{
|
||||
if( ( ret = mbedtls_ssl_cookie_setup( &cookie_ctx,
|
||||
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
|
||||
rng_get, &rng ) ) != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_cookie_setup returned %d\n\n", ret );
|
||||
goto exit;
|
||||
@ -2784,23 +2721,15 @@ int main( int argc, char *argv[] )
|
||||
if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER )
|
||||
mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite );
|
||||
|
||||
#if defined(MBEDTLS_ARC4_C)
|
||||
if( opt.arc4 != DFL_ARC4 )
|
||||
mbedtls_ssl_conf_arc4_support( &conf, opt.arc4 );
|
||||
#endif
|
||||
|
||||
if( opt.version_suites != NULL )
|
||||
{
|
||||
mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[0],
|
||||
MBEDTLS_SSL_MAJOR_VERSION_3,
|
||||
MBEDTLS_SSL_MINOR_VERSION_0 );
|
||||
MBEDTLS_SSL_MINOR_VERSION_1 );
|
||||
mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[1],
|
||||
MBEDTLS_SSL_MAJOR_VERSION_3,
|
||||
MBEDTLS_SSL_MINOR_VERSION_1 );
|
||||
mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[2],
|
||||
MBEDTLS_SSL_MAJOR_VERSION_3,
|
||||
MBEDTLS_SSL_MINOR_VERSION_2 );
|
||||
mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[3],
|
||||
mbedtls_ssl_conf_ciphersuites_for_version( &conf, version_suites[2],
|
||||
MBEDTLS_SSL_MAJOR_VERSION_3,
|
||||
MBEDTLS_SSL_MINOR_VERSION_3 );
|
||||
}
|
||||
@ -2899,8 +2828,8 @@ int main( int argc, char *argv[] )
|
||||
ssl_async_keys.inject_error = ( opt.async_private_error < 0 ?
|
||||
- opt.async_private_error :
|
||||
opt.async_private_error );
|
||||
ssl_async_keys.f_rng = mbedtls_ctr_drbg_random;
|
||||
ssl_async_keys.p_rng = &ctr_drbg;
|
||||
ssl_async_keys.f_rng = rng_get;
|
||||
ssl_async_keys.p_rng = &rng;
|
||||
mbedtls_ssl_conf_async_private_cb( &conf,
|
||||
sign,
|
||||
decrypt,
|
||||
@ -3233,7 +3162,7 @@ handshake:
|
||||
if( ( ret = mbedtls_ssl_get_record_expansion( &ssl ) ) >= 0 )
|
||||
mbedtls_printf( " [ Record expansion is %d ]\n", ret );
|
||||
else
|
||||
mbedtls_printf( " [ Record expansion is unknown (compression) ]\n" );
|
||||
mbedtls_printf( " [ Record expansion is unknown ]\n" );
|
||||
|
||||
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
|
||||
mbedtls_printf( " [ Maximum input fragment length is %u ]\n",
|
||||
@ -3998,8 +3927,7 @@ exit:
|
||||
|
||||
mbedtls_ssl_free( &ssl );
|
||||
mbedtls_ssl_config_free( &conf );
|
||||
mbedtls_ctr_drbg_free( &ctr_drbg );
|
||||
mbedtls_entropy_free( &entropy );
|
||||
rng_free( &rng );
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_C)
|
||||
mbedtls_ssl_cache_free( &cache );
|
||||
@ -4019,12 +3947,32 @@ exit:
|
||||
mbedtls_free( context_buf );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
mbedtls_psa_crypto_free( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
/* Let test hooks detect errors such as resource leaks.
|
||||
* Don't do it in query_config mode, because some test code prints
|
||||
* information to stdout and this gets mixed with the regular output. */
|
||||
if( opt.query_config_mode == DFL_QUERY_CONFIG_MODE )
|
||||
{
|
||||
if( test_hooks_failure_detected( ) )
|
||||
{
|
||||
if( ret == 0 )
|
||||
ret = 1;
|
||||
mbedtls_printf( "Test hooks detected errors.\n" );
|
||||
}
|
||||
}
|
||||
test_hooks_free( );
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_memory_buffer_alloc_status();
|
||||
#endif
|
||||
mbedtls_memory_buffer_alloc_free();
|
||||
#endif
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
|
||||
if( opt.query_config_mode == DFL_QUERY_CONFIG_MODE )
|
||||
{
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#include "ssl_test_lib.h"
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
#include "test/helpers.h"
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
||||
|
||||
void my_debug( void *ctx, int level,
|
||||
@ -46,7 +50,8 @@ mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
|
||||
return 0x5af2a056;
|
||||
}
|
||||
|
||||
int dummy_entropy( void *data, unsigned char *output, size_t len )
|
||||
#if !defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
static int dummy_entropy( void *data, unsigned char *output, size_t len )
|
||||
{
|
||||
size_t i;
|
||||
int ret;
|
||||
@ -60,6 +65,129 @@ int dummy_entropy( void *data, unsigned char *output, size_t len )
|
||||
}
|
||||
return( ret );
|
||||
}
|
||||
#endif
|
||||
|
||||
void rng_init( rng_context_t *rng )
|
||||
{
|
||||
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
(void) rng;
|
||||
psa_crypto_init( );
|
||||
#else /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
mbedtls_ctr_drbg_init( &rng->drbg );
|
||||
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||
mbedtls_hmac_drbg_init( &rng->drbg );
|
||||
#else
|
||||
#error "No DRBG available"
|
||||
#endif
|
||||
|
||||
mbedtls_entropy_init( &rng->entropy );
|
||||
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
}
|
||||
|
||||
int rng_seed( rng_context_t *rng, int reproducible, const char *pers )
|
||||
{
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
if( reproducible )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"MBEDTLS_USE_PSA_CRYPTO does not support reproducible mode.\n" );
|
||||
return( -1 );
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
/* The PSA crypto RNG does its own seeding. */
|
||||
(void) rng;
|
||||
(void) pers;
|
||||
if( reproducible )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"The PSA RNG does not support reproducible mode.\n" );
|
||||
return( -1 );
|
||||
}
|
||||
return( 0 );
|
||||
#else /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
int ( *f_entropy )( void *, unsigned char *, size_t ) =
|
||||
( reproducible ? dummy_entropy : mbedtls_entropy_func );
|
||||
|
||||
if ( reproducible )
|
||||
srand( 1 );
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
int ret = mbedtls_ctr_drbg_seed( &rng->drbg,
|
||||
f_entropy, &rng->entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) );
|
||||
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
const mbedtls_md_type_t md_type = MBEDTLS_MD_SHA256;
|
||||
#elif defined(MBEDTLS_SHA512_C)
|
||||
const mbedtls_md_type_t md_type = MBEDTLS_MD_SHA512;
|
||||
#else
|
||||
#error "No message digest available for HMAC_DRBG"
|
||||
#endif
|
||||
int ret = mbedtls_hmac_drbg_seed( &rng->drbg,
|
||||
mbedtls_md_info_from_type( md_type ),
|
||||
f_entropy, &rng->entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) );
|
||||
#else /* !defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_HMAC_DRBG_C) */
|
||||
#error "No DRBG available"
|
||||
#endif /* !defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_HMAC_DRBG_C) */
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n",
|
||||
(unsigned int) -ret );
|
||||
return( ret );
|
||||
}
|
||||
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void rng_free( rng_context_t *rng )
|
||||
{
|
||||
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
(void) rng;
|
||||
/* Deinitialize the PSA crypto subsystem. This deactivates all PSA APIs.
|
||||
* This is ok because none of our applications try to do any crypto after
|
||||
* deinitializing the RNG. */
|
||||
mbedtls_psa_crypto_free( );
|
||||
#else /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
mbedtls_ctr_drbg_free( &rng->drbg );
|
||||
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||
mbedtls_hmac_drbg_free( &rng->drbg );
|
||||
#else
|
||||
#error "No DRBG available"
|
||||
#endif
|
||||
|
||||
mbedtls_entropy_free( &rng->entropy );
|
||||
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
}
|
||||
|
||||
int rng_get( void *p_rng, unsigned char *output, size_t output_len )
|
||||
{
|
||||
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
(void) p_rng;
|
||||
return( mbedtls_psa_get_random( MBEDTLS_PSA_RANDOM_STATE,
|
||||
output, output_len ) );
|
||||
#else /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
rng_context_t *rng = p_rng;
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
return( mbedtls_ctr_drbg_random( &rng->drbg, output, output_len ) );
|
||||
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||
return( mbedtls_hmac_drbg_random( &rng->drbg, output, output_len ) );
|
||||
#else
|
||||
#error "No DRBG available"
|
||||
#endif
|
||||
|
||||
#endif /* !MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||
int ca_callback( void *data, mbedtls_x509_crt const *child,
|
||||
@ -197,4 +325,33 @@ int idle( mbedtls_net_context *fd,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
|
||||
void test_hooks_init( void )
|
||||
{
|
||||
mbedtls_test_info_reset( );
|
||||
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
mbedtls_test_mutex_usage_init( );
|
||||
#endif
|
||||
}
|
||||
|
||||
int test_hooks_failure_detected( void )
|
||||
{
|
||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||
/* Errors are reported via mbedtls_test_info. */
|
||||
mbedtls_test_mutex_usage_check( );
|
||||
#endif
|
||||
|
||||
if( mbedtls_test_info.result != MBEDTLS_TEST_RESULT_SUCCESS )
|
||||
return( 1 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void test_hooks_free( void )
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#endif /* !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE) */
|
||||
|
@ -43,20 +43,33 @@
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_CTR_DRBG_C) || \
|
||||
!defined(MBEDTLS_ENTROPY_C) || \
|
||||
!defined(MBEDTLS_NET_C) || \
|
||||
#undef HAVE_RNG
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) && \
|
||||
( defined(MBEDTLS_USE_PSA_CRYPTO) || \
|
||||
defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG) )
|
||||
#define HAVE_RNG
|
||||
#elif defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C)
|
||||
#define HAVE_RNG
|
||||
#elif defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_HMAC_DRBG_C) && \
|
||||
( defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) )
|
||||
#define HAVE_RNG
|
||||
#endif
|
||||
|
||||
#if !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"
|
||||
#elif !defined(HAVE_RNG)
|
||||
#define MBEDTLS_SSL_TEST_IMPOSSIBLE \
|
||||
"No random generator is available.\n"
|
||||
#else
|
||||
#undef MBEDTLS_SSL_TEST_IMPOSSIBLE
|
||||
|
||||
#undef HAVE_RNG
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -65,14 +78,15 @@
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/hmac_drbg.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls/timing.h"
|
||||
#include "mbedtls/base64.h"
|
||||
#include "test/certs.h"
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
#include "psa/crypto.h"
|
||||
#include "mbedtls/psa_util.h"
|
||||
#endif
|
||||
@ -126,7 +140,101 @@ void my_debug( void *ctx, int level,
|
||||
|
||||
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
|
||||
|
||||
int dummy_entropy( void *data, unsigned char *output, size_t len );
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/* If MBEDTLS_TEST_USE_PSA_CRYPTO_RNG is defined, the SSL test programs will use
|
||||
* mbedtls_psa_get_random() rather than entropy+DRBG as a random generator.
|
||||
*
|
||||
* The constraints are:
|
||||
* - Without the entropy module, the PSA RNG is the only option.
|
||||
* - Without at least one of the DRBG modules, the PSA RNG is the only option.
|
||||
* - The PSA RNG does not support explicit seeding, so it is incompatible with
|
||||
* the reproducible mode used by test programs.
|
||||
* - For good overall test coverage, there should be at least one configuration
|
||||
* where the test programs use the PSA RNG while the PSA RNG is itself based
|
||||
* on entropy+DRBG, and at least one configuration where the test programs
|
||||
* do not use the PSA RNG even though it's there.
|
||||
*
|
||||
* A simple choice that meets the constraints is to use the PSA RNG whenever
|
||||
* MBEDTLS_USE_PSA_CRYPTO is enabled. There's no real technical reason the
|
||||
* choice to use the PSA RNG in the test programs and the choice to use
|
||||
* PSA crypto when TLS code needs crypto have to be tied together, but it
|
||||
* happens to be a good match. It's also a good match from an application
|
||||
* perspective: either PSA is preferred for TLS (both for crypto and for
|
||||
* random generation) or it isn't.
|
||||
*/
|
||||
#define MBEDTLS_TEST_USE_PSA_CRYPTO_RNG
|
||||
#endif
|
||||
|
||||
/** A context for random number generation (RNG).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#if defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
|
||||
unsigned char dummy;
|
||||
#else /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
mbedtls_entropy_context entropy;
|
||||
#if defined(MBEDTLS_CTR_DRBG_C)
|
||||
mbedtls_ctr_drbg_context drbg;
|
||||
#elif defined(MBEDTLS_HMAC_DRBG_C)
|
||||
mbedtls_hmac_drbg_context drbg;
|
||||
#else
|
||||
#error "No DRBG available"
|
||||
#endif
|
||||
#endif /* MBEDTLS_TEST_USE_PSA_CRYPTO_RNG */
|
||||
} rng_context_t;
|
||||
|
||||
/** Initialize the RNG.
|
||||
*
|
||||
* This function only initializes the memory used by the RNG context.
|
||||
* Before using the RNG, it must be seeded with rng_seed().
|
||||
*/
|
||||
void rng_init( rng_context_t *rng );
|
||||
|
||||
/* Seed the random number generator.
|
||||
*
|
||||
* \param rng The RNG context to use. It must have been initialized
|
||||
* with rng_init().
|
||||
* \param reproducible If zero, seed the RNG from entropy.
|
||||
* If nonzero, use a fixed seed, so that the program
|
||||
* will produce the same sequence of random numbers
|
||||
* each time it is invoked.
|
||||
* \param pers A null-terminated string. Different values for this
|
||||
* string cause the RNG to emit different output for
|
||||
* the same seed.
|
||||
*
|
||||
* return 0 on success, a negative value on error.
|
||||
*/
|
||||
int rng_seed( rng_context_t *rng, int reproducible, const char *pers );
|
||||
|
||||
/** Deinitialize the RNG. Free any embedded resource.
|
||||
*
|
||||
* \param rng The RNG context to deinitialize. It must have been
|
||||
* initialized with rng_init().
|
||||
*/
|
||||
void rng_free( rng_context_t *rng );
|
||||
|
||||
/** Generate random data.
|
||||
*
|
||||
* This function is suitable for use as the \c f_rng argument to Mbed TLS
|
||||
* library functions.
|
||||
*
|
||||
* \param p_rng The random generator context. This must be a pointer to
|
||||
* a #rng_context_t structure.
|
||||
* \param output The buffer to fill.
|
||||
* \param output_len The length of the buffer in bytes.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return An Mbed TLS error code on error.
|
||||
*/
|
||||
int rng_get( void *p_rng, unsigned char *output, size_t output_len );
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
|
||||
/* The test implementation of the PSA external RNG is insecure. When
|
||||
* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled, before using any PSA crypto
|
||||
* function that makes use of an RNG, you must call
|
||||
* mbedtls_test_enable_insecure_external_rng(). */
|
||||
#include <test/fake_external_rng_for_test.h>
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||
int ca_callback( void *data, mbedtls_x509_crt const *child,
|
||||
@ -150,5 +258,37 @@ int idle( mbedtls_net_context *fd,
|
||||
#endif
|
||||
int idle_reason );
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
/** Initialize whatever test hooks are enabled by the compile-time
|
||||
* configuration and make sense for the TLS test programs. */
|
||||
void test_hooks_init( void );
|
||||
|
||||
/** Check if any test hooks detected a problem.
|
||||
*
|
||||
* If a problem was detected, it's ok for the calling program to keep going,
|
||||
* but it should ultimately exit with an error status.
|
||||
*
|
||||
* \note When implementing a test hook that detects errors on its own
|
||||
* (as opposed to e.g. leaving the error for a memory sanitizer to
|
||||
* report), make sure to print a message to standard error either at
|
||||
* the time the problem is detected or during the execution of this
|
||||
* function. This function does not indicate what problem was detected,
|
||||
* so printing a message is the only way to provide feedback in the
|
||||
* logs of the calling program.
|
||||
*
|
||||
* \return Nonzero if a problem was detected.
|
||||
* \c 0 if no problem was detected.
|
||||
*/
|
||||
int test_hooks_failure_detected( void );
|
||||
|
||||
/** Free any resources allocated for the sake of test hooks.
|
||||
*
|
||||
* Call this at the end of the program so that resource leak analyzers
|
||||
* don't complain.
|
||||
*/
|
||||
void test_hooks_free( void );
|
||||
|
||||
#endif /* !MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#endif /* MBEDTLS_SSL_TEST_IMPOSSIBLE conditions: else */
|
||||
#endif /* MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H */
|
||||
|
@ -2,14 +2,6 @@ set(libs
|
||||
${mbedtls_target}
|
||||
)
|
||||
|
||||
if(USE_PKCS11_HELPER_LIBRARY)
|
||||
set(libs ${libs} pkcs11-helper)
|
||||
endif(USE_PKCS11_HELPER_LIBRARY)
|
||||
|
||||
if(ENABLE_ZLIB_SUPPORT)
|
||||
set(libs ${libs} ${ZLIB_LIBRARIES})
|
||||
endif(ENABLE_ZLIB_SUPPORT)
|
||||
|
||||
set(executables_libs
|
||||
selftest
|
||||
udp_proxy
|
||||
@ -33,6 +25,7 @@ foreach(exe IN LISTS executables_libs executables_mbedcrypto)
|
||||
endif()
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
|
||||
${extra_sources})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
|
||||
# This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
|
||||
list(FIND executables_libs ${exe} exe_index)
|
||||
|
@ -265,6 +265,21 @@ void ecp_clear_precomputed( mbedtls_ecp_group *grp )
|
||||
#define ecp_clear_precomputed( g )
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
static int set_ecp_curve( const char *string, mbedtls_ecp_curve_info *curve )
|
||||
{
|
||||
const mbedtls_ecp_curve_info *found =
|
||||
mbedtls_ecp_curve_info_from_name( string );
|
||||
if( found != NULL )
|
||||
{
|
||||
*curve = *found;
|
||||
return( 1 );
|
||||
}
|
||||
else
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned char buf[BUFSIZE];
|
||||
|
||||
typedef struct {
|
||||
@ -288,6 +303,17 @@ int main( int argc, char *argv[] )
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
unsigned char alloc_buf[HEAP_SIZE] = { 0 };
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
mbedtls_ecp_curve_info single_curve[2] = {
|
||||
{ MBEDTLS_ECP_DP_NONE, 0, 0, NULL },
|
||||
{ MBEDTLS_ECP_DP_NONE, 0, 0, NULL },
|
||||
};
|
||||
const mbedtls_ecp_curve_info *curve_list = mbedtls_ecp_curve_list( );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
(void) curve_list; /* Unused in some configurations where no benchmark uses ECC */
|
||||
#endif
|
||||
|
||||
if( argc <= 1 )
|
||||
{
|
||||
@ -353,6 +379,10 @@ int main( int argc, char *argv[] )
|
||||
todo.ecdsa = 1;
|
||||
else if( strcmp( argv[i], "ecdh" ) == 0 )
|
||||
todo.ecdh = 1;
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
else if( set_ecp_curve( argv[i], single_curve ) )
|
||||
curve_list = single_curve;
|
||||
#endif
|
||||
else
|
||||
{
|
||||
mbedtls_printf( "Unrecognized option: %s\n", argv[i] );
|
||||
@ -832,7 +862,7 @@ int main( int argc, char *argv[] )
|
||||
|
||||
memset( buf, 0x2A, sizeof( buf ) );
|
||||
|
||||
for( curve_info = mbedtls_ecp_curve_list();
|
||||
for( curve_info = curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
@ -854,7 +884,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_ecdsa_free( &ecdsa );
|
||||
}
|
||||
|
||||
for( curve_info = mbedtls_ecp_curve_list();
|
||||
for( curve_info = curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
@ -898,8 +928,23 @@ int main( int argc, char *argv[] )
|
||||
};
|
||||
const mbedtls_ecp_curve_info *curve_info;
|
||||
size_t olen;
|
||||
const mbedtls_ecp_curve_info *selected_montgomery_curve_list =
|
||||
montgomery_curve_list;
|
||||
|
||||
for( curve_info = mbedtls_ecp_curve_list();
|
||||
if( curve_list == (const mbedtls_ecp_curve_info*) &single_curve )
|
||||
{
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
if( mbedtls_ecp_group_load( &grp, curve_list->grp_id ) != 0 )
|
||||
mbedtls_exit( 1 );
|
||||
if( mbedtls_ecp_get_type( &grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
|
||||
selected_montgomery_curve_list = single_curve;
|
||||
else /* empty list */
|
||||
selected_montgomery_curve_list = single_curve + 1;
|
||||
mbedtls_ecp_group_free( &grp );
|
||||
}
|
||||
|
||||
for( curve_info = curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
@ -925,7 +970,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
/* Montgomery curves need to be handled separately */
|
||||
for ( curve_info = montgomery_curve_list;
|
||||
for ( curve_info = selected_montgomery_curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
@ -947,7 +992,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_mpi_free( &z );
|
||||
}
|
||||
|
||||
for( curve_info = mbedtls_ecp_curve_list();
|
||||
for( curve_info = curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++ )
|
||||
{
|
||||
@ -973,7 +1018,7 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
/* Montgomery curves need to be handled separately */
|
||||
for ( curve_info = montgomery_curve_list;
|
||||
for ( curve_info = selected_montgomery_curve_list;
|
||||
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
|
||||
curve_info++)
|
||||
{
|
||||
@ -1002,7 +1047,6 @@ int main( int argc, char *argv[] )
|
||||
{
|
||||
mbedtls_ecdh_context ecdh_srv, ecdh_cli;
|
||||
unsigned char buf_srv[BUFSIZE], buf_cli[BUFSIZE];
|
||||
const mbedtls_ecp_curve_info * curve_list = mbedtls_ecp_curve_list();
|
||||
const mbedtls_ecp_curve_info *curve_info;
|
||||
size_t olen;
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#endif
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
#include "mbedtls/aesni.h"
|
||||
#include "mbedtls/arc4.h"
|
||||
#include "mbedtls/aria.h"
|
||||
#include "mbedtls/asn1.h"
|
||||
@ -33,17 +32,14 @@
|
||||
#include "mbedtls/base64.h"
|
||||
#include "mbedtls/bignum.h"
|
||||
#include "mbedtls/blowfish.h"
|
||||
#include "mbedtls/bn_mul.h"
|
||||
#include "mbedtls/camellia.h"
|
||||
#include "mbedtls/ccm.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/chacha20.h"
|
||||
#include "mbedtls/chachapoly.h"
|
||||
#include "mbedtls/check_config.h"
|
||||
#include "mbedtls/cipher.h"
|
||||
#include "mbedtls/cipher_internal.h"
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/compat-1.3.h"
|
||||
#include "mbedtls/config_psa.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls/des.h"
|
||||
@ -52,9 +48,7 @@
|
||||
#include "mbedtls/ecdsa.h"
|
||||
#include "mbedtls/ecjpake.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/ecp_internal.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/gcm.h"
|
||||
#include "mbedtls/hkdf.h"
|
||||
@ -63,15 +57,11 @@
|
||||
#include "mbedtls/md2.h"
|
||||
#include "mbedtls/md4.h"
|
||||
#include "mbedtls/md5.h"
|
||||
#include "mbedtls/md_internal.h"
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/nist_kw.h"
|
||||
#include "mbedtls/oid.h"
|
||||
#include "mbedtls/padlock.h"
|
||||
#include "mbedtls/pem.h"
|
||||
#include "mbedtls/pk.h"
|
||||
#include "mbedtls/pk_internal.h"
|
||||
#include "mbedtls/pkcs11.h"
|
||||
#include "mbedtls/pkcs12.h"
|
||||
#include "mbedtls/pkcs5.h"
|
||||
#include "mbedtls/platform_time.h"
|
||||
@ -80,7 +70,6 @@
|
||||
#include "mbedtls/psa_util.h"
|
||||
#include "mbedtls/ripemd160.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
#include "mbedtls/rsa_internal.h"
|
||||
#include "mbedtls/sha1.h"
|
||||
#include "mbedtls/sha256.h"
|
||||
#include "mbedtls/sha512.h"
|
||||
@ -88,7 +77,6 @@
|
||||
#include "mbedtls/ssl_cache.h"
|
||||
#include "mbedtls/ssl_ciphersuites.h"
|
||||
#include "mbedtls/ssl_cookie.h"
|
||||
#include "mbedtls/ssl_internal.h"
|
||||
#include "mbedtls/ssl_ticket.h"
|
||||
#include "mbedtls/threading.h"
|
||||
#include "mbedtls/timing.h"
|
||||
@ -109,7 +97,6 @@
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "psa/crypto_se_driver.h"
|
||||
#include "../library/psa_crypto_its.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -37,7 +37,6 @@
|
||||
* default value when that configuration is not set in the config.h.
|
||||
*/
|
||||
#include "mbedtls/aes.h"
|
||||
#include "mbedtls/aesni.h"
|
||||
#include "mbedtls/arc4.h"
|
||||
#include "mbedtls/aria.h"
|
||||
#include "mbedtls/asn1.h"
|
||||
@ -47,7 +46,6 @@
|
||||
#include "mbedtls/blowfish.h"
|
||||
#include "mbedtls/camellia.h"
|
||||
#include "mbedtls/ccm.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/chacha20.h"
|
||||
#include "mbedtls/chachapoly.h"
|
||||
#include "mbedtls/cipher.h"
|
||||
@ -61,7 +59,6 @@
|
||||
#include "mbedtls/ecjpake.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/gcm.h"
|
||||
#include "mbedtls/hkdf.h"
|
||||
@ -74,10 +71,8 @@
|
||||
#include "mbedtls/net_sockets.h"
|
||||
#include "mbedtls/nist_kw.h"
|
||||
#include "mbedtls/oid.h"
|
||||
#include "mbedtls/padlock.h"
|
||||
#include "mbedtls/pem.h"
|
||||
#include "mbedtls/pk.h"
|
||||
#include "mbedtls/pkcs11.h"
|
||||
#include "mbedtls/pkcs12.h"
|
||||
#include "mbedtls/pkcs5.h"
|
||||
#include "mbedtls/platform_time.h"
|
||||
@ -92,7 +87,6 @@
|
||||
#include "mbedtls/ssl_cache.h"
|
||||
#include "mbedtls/ssl_ciphersuites.h"
|
||||
#include "mbedtls/ssl_cookie.h"
|
||||
#include "mbedtls/ssl_internal.h"
|
||||
#include "mbedtls/ssl_ticket.h"
|
||||
#include "mbedtls/threading.h"
|
||||
#include "mbedtls/timing.h"
|
||||
@ -657,6 +651,14 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_INTERNAL_ALT */
|
||||
|
||||
#if defined(MBEDTLS_ECP_NO_FALLBACK)
|
||||
if( strcmp( "MBEDTLS_ECP_NO_FALLBACK", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NO_FALLBACK );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ECP_NO_FALLBACK */
|
||||
|
||||
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
|
||||
if( strcmp( "MBEDTLS_ECP_RANDOMIZE_JAC_ALT", config ) == 0 )
|
||||
{
|
||||
@ -857,14 +859,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */
|
||||
|
||||
#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES)
|
||||
if( strcmp( "MBEDTLS_REMOVE_ARC4_CIPHERSUITES", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_REMOVE_ARC4_CIPHERSUITES );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */
|
||||
|
||||
#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES)
|
||||
if( strcmp( "MBEDTLS_REMOVE_3DES_CIPHERSUITES", config ) == 0 )
|
||||
{
|
||||
@ -1217,6 +1211,14 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_PKCS1_V21 */
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_CLIENT)
|
||||
if( strcmp( "MBEDTLS_PSA_CRYPTO_CLIENT", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_PSA_CRYPTO_CLIENT );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_CLIENT */
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS)
|
||||
if( strcmp( "MBEDTLS_PSA_CRYPTO_DRIVERS", config ) == 0 )
|
||||
{
|
||||
@ -1369,14 +1371,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */
|
||||
|
||||
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
||||
if( strcmp( "MBEDTLS_SSL_HW_RECORD_ACCEL", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_HW_RECORD_ACCEL );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
|
||||
if( strcmp( "MBEDTLS_SSL_CBC_RECORD_SPLITTING", config ) == 0 )
|
||||
{
|
||||
@ -1393,14 +1387,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO)
|
||||
if( strcmp( "MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
|
||||
if( strcmp( "MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE", config ) == 0 )
|
||||
{
|
||||
@ -1417,14 +1403,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_SSL3)
|
||||
if( strcmp( "MBEDTLS_SSL_PROTO_SSL3", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_SSL3 );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1)
|
||||
if( strcmp( "MBEDTLS_SSL_PROTO_TLS1", config ) == 0 )
|
||||
{
|
||||
@ -1545,14 +1523,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
|
||||
|
||||
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT)
|
||||
if( strcmp( "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH)
|
||||
if( strcmp( "MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH", config ) == 0 )
|
||||
{
|
||||
@ -1673,14 +1643,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */
|
||||
|
||||
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||
if( strcmp( "MBEDTLS_ZLIB_SUPPORT", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_ZLIB_SUPPORT );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_ZLIB_SUPPORT */
|
||||
|
||||
#if defined(MBEDTLS_AESNI_C)
|
||||
if( strcmp( "MBEDTLS_AESNI_C", config ) == 0 )
|
||||
{
|
||||
@ -1769,14 +1731,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_CCM_C */
|
||||
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
if( strcmp( "MBEDTLS_CERTS_C", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_CERTS_C );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
|
||||
#if defined(MBEDTLS_CHACHA20_C)
|
||||
if( strcmp( "MBEDTLS_CHACHA20_C", config ) == 0 )
|
||||
{
|
||||
@ -2033,14 +1987,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_PKCS5_C */
|
||||
|
||||
#if defined(MBEDTLS_PKCS11_C)
|
||||
if( strcmp( "MBEDTLS_PKCS11_C", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS11_C );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PKCS11_C */
|
||||
|
||||
#if defined(MBEDTLS_PKCS12_C)
|
||||
if( strcmp( "MBEDTLS_PKCS12_C", config ) == 0 )
|
||||
{
|
||||
@ -2617,6 +2563,14 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_PSA_HMAC_DRBG_MD_TYPE */
|
||||
|
||||
#if defined(MBEDTLS_PSA_KEY_SLOT_COUNT)
|
||||
if( strcmp( "MBEDTLS_PSA_KEY_SLOT_COUNT", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_PSA_KEY_SLOT_COUNT );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PSA_KEY_SLOT_COUNT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT)
|
||||
if( strcmp( "MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT", config ) == 0 )
|
||||
{
|
||||
@ -2697,14 +2651,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_MAX_BUFFERING */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME)
|
||||
if( strcmp( "MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME */
|
||||
|
||||
#if defined(MBEDTLS_PSK_MAX_LEN)
|
||||
if( strcmp( "MBEDTLS_PSK_MAX_LEN", config ) == 0 )
|
||||
{
|
||||
@ -2737,14 +2683,6 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_X509_MAX_FILE_PATH_LEN */
|
||||
|
||||
#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES)
|
||||
if( strcmp( "MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES */
|
||||
|
||||
#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE)
|
||||
if( strcmp( "MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE", config ) == 0 )
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
#include "mbedtls/hmac_drbg.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/dhm.h"
|
||||
@ -315,9 +314,6 @@ const selftest_t selftests[] =
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
{"rsa", mbedtls_rsa_self_test},
|
||||
#endif
|
||||
#if defined(MBEDTLS_X509_USE_C)
|
||||
{"x509", mbedtls_x509_self_test},
|
||||
#endif
|
||||
#if defined(MBEDTLS_XTEA_C)
|
||||
{"xtea", mbedtls_xtea_self_test},
|
||||
#endif
|
||||
|
@ -2,14 +2,6 @@ set(libs
|
||||
${mbedx509_target}
|
||||
)
|
||||
|
||||
if(USE_PKCS11_HELPER_LIBRARY)
|
||||
set(libs ${libs} pkcs11-helper)
|
||||
endif(USE_PKCS11_HELPER_LIBRARY)
|
||||
|
||||
if(ENABLE_ZLIB_SUPPORT)
|
||||
set(libs ${libs} ${ZLIB_LIBRARIES})
|
||||
endif(ENABLE_ZLIB_SUPPORT)
|
||||
|
||||
set(executables
|
||||
cert_app
|
||||
cert_req
|
||||
|
Reference in New Issue
Block a user