mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 12:25:26 +00:00
Merge remote-tracking branch 'origin/pr/2469' into development
* origin/pr/2469: Enable MBEDTLS_MEMORY_DEBUG in memory buffer alloc test in all.sh Remove unnecessary memory buffer alloc unsets Disable DTLS proxy tests for MEMORY_BUFFER_ALLOC test all.sh: restructure memory allocator tests Add missing dependency in memory buffer alloc set in all.sh Don't set MBEDTLS_MEMORY_DEBUG through `scripts/config.pl full` Add cfg dep MBEDTLS_MEMORY_DEBUG->MBEDTLS_MEMORY_BUFFER_ALLOC_C Fix memory leak in CSR test suite on failure Fix a memory leak in x509write test suite Add all.sh run with full config and ASan enabled Add all.sh run with MBEDTLS_MEMORY_BUFFER_ALLOC_C enabled Update documentation of exceptions for `config.pl full` Adapt all.sh to removal of buffer allocator from full config Disable memory buffer allocator in full config Check dependencies of MBEDTLS_MEMORY_BACKTRACE in check_config.h
This commit is contained in:
commit
62be28b525
|
@ -305,6 +305,14 @@
|
||||||
#error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
|
#error "MBEDTLS_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MEMORY_BACKTRACE) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||||
|
#error "MBEDTLS_MEMORY_BACKTRACE defined, but not all prerequesites"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MEMORY_DEBUG) && !defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||||
|
#error "MBEDTLS_MEMORY_DEBUG defined, but not all prerequesites"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM)
|
#if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM)
|
||||||
#error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
|
#error "MBEDTLS_PADLOCK_C defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
# MBEDTLS_ECP_DP_M221_ENABLED
|
# MBEDTLS_ECP_DP_M221_ENABLED
|
||||||
# MBEDTLS_ECP_DP_M383_ENABLED
|
# MBEDTLS_ECP_DP_M383_ENABLED
|
||||||
# MBEDTLS_ECP_DP_M511_ENABLED
|
# MBEDTLS_ECP_DP_M511_ENABLED
|
||||||
|
# MBEDTLS_MEMORY_BACKTRACE
|
||||||
|
# MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
# MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
# MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
||||||
# MBEDTLS_NO_PLATFORM_ENTROPY
|
# MBEDTLS_NO_PLATFORM_ENTROPY
|
||||||
# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
|
# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
|
||||||
|
@ -37,6 +39,8 @@
|
||||||
# - this could be enabled if the respective tests were adapted
|
# - this could be enabled if the respective tests were adapted
|
||||||
# MBEDTLS_ZLIB_SUPPORT
|
# MBEDTLS_ZLIB_SUPPORT
|
||||||
# MBEDTLS_PKCS11_C
|
# MBEDTLS_PKCS11_C
|
||||||
|
# MBEDTLS_NO_UDBL_DIVISION
|
||||||
|
# MBEDTLS_NO_64BIT_MULTIPLICATION
|
||||||
# MBEDTLS_PSA_CRYPTO_SPM
|
# MBEDTLS_PSA_CRYPTO_SPM
|
||||||
# MBEDTLS_PSA_INJECT_ENTROPY
|
# MBEDTLS_PSA_INJECT_ENTROPY
|
||||||
# MBEDTLS_ECP_RESTARTABLE
|
# MBEDTLS_ECP_RESTARTABLE
|
||||||
|
@ -89,6 +93,9 @@ MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
|
||||||
MBEDTLS_ECP_DP_M221_ENABLED
|
MBEDTLS_ECP_DP_M221_ENABLED
|
||||||
MBEDTLS_ECP_DP_M383_ENABLED
|
MBEDTLS_ECP_DP_M383_ENABLED
|
||||||
MBEDTLS_ECP_DP_M511_ENABLED
|
MBEDTLS_ECP_DP_M511_ENABLED
|
||||||
|
MBEDTLS_MEMORY_DEBUG
|
||||||
|
MBEDTLS_MEMORY_BACKTRACE
|
||||||
|
MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
|
||||||
MBEDTLS_NO_PLATFORM_ENTROPY
|
MBEDTLS_NO_PLATFORM_ENTROPY
|
||||||
MBEDTLS_RSA_NO_CRT
|
MBEDTLS_RSA_NO_CRT
|
||||||
|
|
|
@ -660,6 +660,22 @@ component_test_default_cmake_gcc_asan () {
|
||||||
if_build_succeeded tests/compat.sh
|
if_build_succeeded tests/compat.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component_test_full_cmake_gcc_asan () {
|
||||||
|
msg "build: full config, cmake, gcc, ASan"
|
||||||
|
scripts/config.pl full
|
||||||
|
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||||
|
make
|
||||||
|
|
||||||
|
msg "test: main suites (inc. selftests) (full config, ASan build)"
|
||||||
|
make test
|
||||||
|
|
||||||
|
msg "test: ssl-opt.sh (full config, ASan build)"
|
||||||
|
if_build_succeeded tests/ssl-opt.sh
|
||||||
|
|
||||||
|
msg "test: compat.sh (full config, ASan build)"
|
||||||
|
if_build_succeeded tests/compat.sh
|
||||||
|
}
|
||||||
|
|
||||||
component_test_ref_configs () {
|
component_test_ref_configs () {
|
||||||
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
|
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
|
||||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||||
|
@ -789,7 +805,6 @@ component_test_small_mbedtls_ssl_dtls_max_buffering () {
|
||||||
component_test_full_cmake_clang () {
|
component_test_full_cmake_clang () {
|
||||||
msg "build: cmake, full config, clang" # ~ 50s
|
msg "build: cmake, full config, clang" # ~ 50s
|
||||||
scripts/config.pl full
|
scripts/config.pl full
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
|
|
||||||
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
|
CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
|
||||||
make
|
make
|
||||||
|
|
||||||
|
@ -859,7 +874,6 @@ component_test_no_use_psa_crypto_full_cmake_asan() {
|
||||||
# full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
|
# full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
|
||||||
msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
|
msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
|
||||||
scripts/config.pl full
|
scripts/config.pl full
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # slow and makes ASan mostly ineffective
|
|
||||||
scripts/config.pl set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
|
scripts/config.pl set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
|
||||||
scripts/config.pl unset MBEDTLS_PSA_CRYPTO_C
|
scripts/config.pl unset MBEDTLS_PSA_CRYPTO_C
|
||||||
scripts/config.pl unset MBEDTLS_USE_PSA_CRYPTO
|
scripts/config.pl unset MBEDTLS_USE_PSA_CRYPTO
|
||||||
|
@ -892,7 +906,6 @@ component_test_check_params_functionality () {
|
||||||
scripts/config.pl full # includes CHECK_PARAMS
|
scripts/config.pl full # includes CHECK_PARAMS
|
||||||
# Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
|
# Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
|
||||||
scripts/config.pl unset MBEDTLS_CHECK_PARAMS_ASSERT
|
scripts/config.pl unset MBEDTLS_CHECK_PARAMS_ASSERT
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
|
||||||
# Only build and run tests. Do not build sample programs, because
|
# Only build and run tests. Do not build sample programs, because
|
||||||
# they don't have a mbedtls_param_failed() function.
|
# they don't have a mbedtls_param_failed() function.
|
||||||
make CC=gcc CFLAGS='-Werror -O1' lib test
|
make CC=gcc CFLAGS='-Werror -O1' lib test
|
||||||
|
@ -902,7 +915,6 @@ component_test_check_params_without_platform () {
|
||||||
msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
|
msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
|
||||||
scripts/config.pl full # includes CHECK_PARAMS
|
scripts/config.pl full # includes CHECK_PARAMS
|
||||||
# Keep MBEDTLS_PARAM_FAILED as assert.
|
# Keep MBEDTLS_PARAM_FAILED as assert.
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
|
||||||
scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
|
scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
|
||||||
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
|
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
|
||||||
scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
|
scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
|
||||||
|
@ -917,7 +929,6 @@ component_test_check_params_without_platform () {
|
||||||
component_test_check_params_silent () {
|
component_test_check_params_silent () {
|
||||||
msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
|
msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
|
||||||
scripts/config.pl full # includes CHECK_PARAMS
|
scripts/config.pl full # includes CHECK_PARAMS
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
|
|
||||||
# Set MBEDTLS_PARAM_FAILED to nothing.
|
# Set MBEDTLS_PARAM_FAILED to nothing.
|
||||||
sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
|
sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
|
||||||
make CC=gcc CFLAGS='-Werror -O1' all test
|
make CC=gcc CFLAGS='-Werror -O1' all test
|
||||||
|
@ -938,7 +949,6 @@ component_test_no_platform () {
|
||||||
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
|
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT
|
||||||
scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
|
scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT
|
||||||
scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
|
scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
|
||||||
scripts/config.pl unset MBEDTLS_FS_IO
|
scripts/config.pl unset MBEDTLS_FS_IO
|
||||||
scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C
|
scripts/config.pl unset MBEDTLS_PSA_CRYPTO_STORAGE_C
|
||||||
scripts/config.pl unset MBEDTLS_PSA_ITS_FILE_C
|
scripts/config.pl unset MBEDTLS_PSA_ITS_FILE_C
|
||||||
|
@ -981,6 +991,34 @@ component_build_no_sockets () {
|
||||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
|
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component_test_memory_buffer_allocator_backtrace () {
|
||||||
|
msg "build: default config with memory buffer allocator and backtrace enabled"
|
||||||
|
scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
|
scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
|
||||||
|
scripts/config.pl set MBEDTLS_MEMORY_BACKTRACE
|
||||||
|
scripts/config.pl set MBEDTLS_MEMORY_DEBUG
|
||||||
|
CC=gcc cmake .
|
||||||
|
make
|
||||||
|
|
||||||
|
msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
|
||||||
|
make test
|
||||||
|
}
|
||||||
|
|
||||||
|
component_test_memory_buffer_allocator () {
|
||||||
|
msg "build: default config with memory buffer allocator"
|
||||||
|
scripts/config.pl set MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||||
|
scripts/config.pl set MBEDTLS_PLATFORM_MEMORY
|
||||||
|
CC=gcc cmake .
|
||||||
|
make
|
||||||
|
|
||||||
|
msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
|
||||||
|
make test
|
||||||
|
|
||||||
|
msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
|
||||||
|
# MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
|
||||||
|
if_build_succeeded tests/ssl-opt.sh -e '^DTLS proxy'
|
||||||
|
}
|
||||||
|
|
||||||
component_test_no_max_fragment_length () {
|
component_test_no_max_fragment_length () {
|
||||||
# Run max fragment length tests with MFL disabled
|
# Run max fragment length tests with MFL disabled
|
||||||
msg "build: default config except MFL extension (ASan build)" # ~ 30s
|
msg "build: default config except MFL extension (ASan build)" # ~ 30s
|
||||||
|
@ -1090,7 +1128,6 @@ component_test_m32_o0 () {
|
||||||
# Build once with -O0, to compile out the i386 specific inline assembly
|
# Build once with -O0, to compile out the i386 specific inline assembly
|
||||||
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
|
||||||
scripts/config.pl full
|
scripts/config.pl full
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # slow and makes ASan mostly ineffective
|
|
||||||
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
||||||
|
|
||||||
msg "test: i386, make, gcc -O0 (ASan build)"
|
msg "test: i386, make, gcc -O0 (ASan build)"
|
||||||
|
@ -1107,7 +1144,6 @@ component_test_m32_o1 () {
|
||||||
# Build again with -O1, to compile in the i386 specific inline assembly
|
# Build again with -O1, to compile in the i386 specific inline assembly
|
||||||
msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
|
msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s
|
||||||
scripts/config.pl full
|
scripts/config.pl full
|
||||||
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # slow and makes ASan mostly ineffective
|
|
||||||
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' LDFLAGS='-m32 -fsanitize=address'
|
||||||
|
|
||||||
msg "test: i386, make, gcc -O1 (ASan build)"
|
msg "test: i386, make, gcc -O1 (ASan build)"
|
||||||
|
|
|
@ -39,25 +39,36 @@ static int x509_crt_verifycsr( const unsigned char *buf, size_t buflen )
|
||||||
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
|
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
|
||||||
const mbedtls_md_info_t *md_info;
|
const mbedtls_md_info_t *md_info;
|
||||||
mbedtls_x509_csr csr;
|
mbedtls_x509_csr csr;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
mbedtls_x509_csr_init( &csr );
|
||||||
|
|
||||||
if( mbedtls_x509_csr_parse( &csr, buf, buflen ) != 0 )
|
if( mbedtls_x509_csr_parse( &csr, buf, buflen ) != 0 )
|
||||||
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
|
{
|
||||||
|
ret = MBEDTLS_ERR_X509_BAD_INPUT_DATA;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
md_info = mbedtls_md_info_from_type( csr.sig_md );
|
md_info = mbedtls_md_info_from_type( csr.sig_md );
|
||||||
if( mbedtls_md( md_info, csr.cri.p, csr.cri.len, hash ) != 0 )
|
if( mbedtls_md( md_info, csr.cri.p, csr.cri.len, hash ) != 0 )
|
||||||
{
|
{
|
||||||
/* Note: this can't happen except after an internal error */
|
/* Note: this can't happen except after an internal error */
|
||||||
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
|
ret = MBEDTLS_ERR_X509_BAD_INPUT_DATA;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mbedtls_pk_verify_ext( csr.sig_pk, csr.sig_opts, &csr.pk,
|
if( mbedtls_pk_verify_ext( csr.sig_pk, csr.sig_opts, &csr.pk,
|
||||||
csr.sig_md, hash, mbedtls_md_get_size( md_info ),
|
csr.sig_md, hash, mbedtls_md_get_size( md_info ),
|
||||||
csr.sig.p, csr.sig.len ) != 0 )
|
csr.sig.p, csr.sig.len ) != 0 )
|
||||||
{
|
{
|
||||||
return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
|
ret = MBEDTLS_ERR_X509_CERT_VERIFY_FAILED;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return( 0 );
|
cleanup:
|
||||||
|
|
||||||
|
mbedtls_x509_csr_free( &csr );
|
||||||
|
return( ret );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
#endif /* MBEDTLS_USE_PSA_CRYPTO */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue