diff --git a/3rdparty/everest/CMakeLists.txt b/3rdparty/everest/CMakeLists.txt index e0e5adecd1..8c8e8db04a 100644 --- a/3rdparty/everest/CMakeLists.txt +++ b/3rdparty/everest/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(${everest_target} target_include_directories(${everest_target} PUBLIC $ $ + $ $ PRIVATE include/everest include/everest/kremlib diff --git a/3rdparty/p256-m/CMakeLists.txt b/3rdparty/p256-m/CMakeLists.txt index 2ef0d48b7d..bd302a7b66 100644 --- a/3rdparty/p256-m/CMakeLists.txt +++ b/3rdparty/p256-m/CMakeLists.txt @@ -8,6 +8,7 @@ target_include_directories(${p256m_target} PUBLIC $ $ $ + $ $ PRIVATE ${MBEDTLS_DIR}/library/) diff --git a/CMakeLists.txt b/CMakeLists.txt index e47667545a..b50dac9fc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,6 +349,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS) target_include_directories(mbedtls_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library) # Request C11, needed for memory poisoning tests set_target_properties(mbedtls_test PROPERTIES C_STANDARD 11) @@ -359,6 +360,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS) target_include_directories(mbedtls_test_helpers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/library PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/everest/include) diff --git a/framework b/framework index 623c1b4532..030b14c2bc 160000 --- a/framework +++ b/framework @@ -1 +1 @@ -Subproject commit 623c1b4532e8de64a5d82ea84a7496e64c370d15 +Subproject commit 030b14c2bce1dff5bd28b08b2c00b6bc1fdd66d5 diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 37a9724559..5ccbe64161 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -329,6 +329,7 @@ foreach(target IN LISTS target_libraries) # of /library (which currently means: under /3rdparty). target_include_directories(${target} PUBLIC $ + $ $ PRIVATE ${MBEDTLS_DIR}/library/ # Needed to include psa_crypto_driver_wrappers.h diff --git a/library/Makefile b/library/Makefile index 388fcea612..4eadf41053 100644 --- a/library/Makefile +++ b/library/Makefile @@ -28,11 +28,11 @@ CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral LDFLAGS ?= -# Include ../include for public headers and . for private headers. -# Note that . needs to be included explicitly for the sake of library -# files that are not in the /library directory (which currently means +# Include ../include, ../tf-psa-crypto/include for public headers and . for +# private headers. Note that . needs to be included explicitly for the sake of +# library files that are not in the /library directory (which currently means # under /3rdparty). -LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -D_FILE_OFFSET_BITS=64 +LOCAL_CFLAGS = $(WARNING_CFLAGS) -I. -I../include -I../tf-psa-crypto/include -D_FILE_OFFSET_BITS=64 LOCAL_LDFLAGS = ifdef DEBUG diff --git a/programs/Makefile b/programs/Makefile index 8d1da6dbe7..9b48cc0f05 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -127,8 +127,8 @@ GENERATED_FILES = psa/psa_constant_names_generated.c test/query_config.c generated_files: $(GENERATED_FILES) psa/psa_constant_names_generated.c: $(gen_file_dep) ../scripts/generate_psa_constants.py -psa/psa_constant_names_generated.c: $(gen_file_dep) ../include/psa/crypto_values.h -psa/psa_constant_names_generated.c: $(gen_file_dep) ../include/psa/crypto_extra.h +psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_values.h +psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_extra.h psa/psa_constant_names_generated.c: $(gen_file_dep) ../tests/suites/test_suite_psa_crypto_metadata.data psa/psa_constant_names_generated.c: echo " Gen $@" diff --git a/programs/psa/CMakeLists.txt b/programs/psa/CMakeLists.txt index a8e4b0e372..c0843e1233 100644 --- a/programs/psa/CMakeLists.txt +++ b/programs/psa/CMakeLists.txt @@ -19,8 +19,8 @@ if(GEN_FILES) ${CMAKE_CURRENT_SOURCE_DIR}/../.. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_extra.h ) else() link_to_source(psa_constant_names_generated.c) diff --git a/programs/test/CMakeLists.txt b/programs/test/CMakeLists.txt index 0d43ffddd3..08fb321312 100644 --- a/programs/test/CMakeLists.txt +++ b/programs/test/CMakeLists.txt @@ -25,14 +25,18 @@ if(TEST_CPP) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}") - target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) + target_include_directories(cpp_dummy_build + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include) target_link_libraries(cpp_dummy_build ${mbedcrypto_target} ${CMAKE_THREAD_LIBS_INIT}) endif() if(USE_SHARED_MBEDTLS_LIBRARY AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") add_executable(dlopen "dlopen.c") - target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) + target_include_directories(dlopen + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include) target_link_libraries(dlopen ${CMAKE_DL_LIBS}) endif() @@ -46,13 +50,13 @@ if(GEN_FILES) ${PERL} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt ${CMAKE_CURRENT_BINARY_DIR}/query_config.c DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_config.h ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt ) # this file will also be used in another directory, so create a target, see diff --git a/scripts/common.make b/scripts/common.make index 9908a3c265..702ef5c670 100644 --- a/scripts/common.make +++ b/scripts/common.make @@ -21,7 +21,7 @@ WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral WARNING_CXXFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral LDFLAGS ?= -LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I$(MBEDTLS_PATH)/include -D_FILE_OFFSET_BITS=64 +LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I$(MBEDTLS_PATH)/include -I$(MBEDTLS_PATH)/tf-psa-crypto/include -D_FILE_OFFSET_BITS=64 LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I$(MBEDTLS_PATH)/include -I$(MBEDTLS_PATH)/tests/include -D_FILE_OFFSET_BITS=64 LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \ -L$(MBEDTLS_PATH)/library \ diff --git a/scripts/generate_psa_constants.py b/scripts/generate_psa_constants.py index d57d46a299..d472c6dc51 100755 --- a/scripts/generate_psa_constants.py +++ b/scripts/generate_psa_constants.py @@ -328,6 +328,7 @@ if __name__ == '__main__': build_tree.chdir_to_root() # Allow to change the directory where psa_constant_names_generated.c is written to. OUTPUT_FILE_DIR = sys.argv[1] if len(sys.argv) == 2 else "programs/psa" - generate_psa_constants(['include/psa/crypto_values.h', - 'include/psa/crypto_extra.h'], + + generate_psa_constants(['tf-psa-crypto/include/psa/crypto_values.h', + 'tf-psa-crypto/include/psa/crypto_extra.h'], OUTPUT_FILE_DIR + '/psa_constant_names_generated.c') diff --git a/scripts/generate_query_config.pl b/scripts/generate_query_config.pl index 39743da6d1..6a2f9cbdfa 100755 --- a/scripts/generate_query_config.pl +++ b/scripts/generate_query_config.pl @@ -26,7 +26,7 @@ use strict; my ($mbedtls_config_file, $psa_crypto_config_file, $query_config_format_file, $query_config_file); my $default_mbedtls_config_file = "./include/mbedtls/mbedtls_config.h"; -my $default_psa_crypto_config_file = "./include/psa/crypto_config.h"; +my $default_psa_crypto_config_file = "./tf-psa-crypto/include/psa/crypto_config.h"; my $default_query_config_format_file = "./scripts/data_files/query_config.fmt"; my $default_query_config_file = "./programs/test/query_config.c"; diff --git a/scripts/generate_visualc_files.pl b/scripts/generate_visualc_files.pl index a0dfc57bff..b566372e1a 100755 --- a/scripts/generate_visualc_files.pl +++ b/scripts/generate_visualc_files.pl @@ -23,7 +23,7 @@ my $vsx_sln_file = "$vsx_dir/mbedTLS.sln"; my $programs_dir = 'programs'; my $mbedtls_header_dir = 'include/mbedtls'; -my $psa_header_dir = 'include/psa'; +my $psa_header_dir = 'tf-psa-crypto/include/psa'; my $source_dir = 'library'; my $test_source_dir = 'tests/src'; my $test_header_dir = 'tests/include/test'; @@ -44,6 +44,7 @@ my @thirdparty_source_dirs = qw( # one directory: the compiler will use the first match. my @include_directories = qw( include + tf-psa-crypto/include 3rdparty/everest/include/ 3rdparty/everest/include/everest 3rdparty/everest/include/everest/vs2013 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5bc38b4e70..62be14e533 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -126,9 +126,9 @@ if(GEN_FILES) ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/psa_storage.py ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/test_case.py ${CMAKE_CURRENT_SOURCE_DIR}/../framework/scripts/mbedtls_framework/test_data_generation.py - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_config.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_values.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/psa/crypto_extra.h + ${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_values.h + ${CMAKE_CURRENT_SOURCE_DIR}/../tf-psa-crypto/include/psa/crypto_extra.h ) else() diff --git a/tests/Makefile b/tests/Makefile index 1d5c76823c..6367b3eb82 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -84,9 +84,9 @@ generated_psa_test_data: ../framework/scripts/mbedtls_framework/test_data_genera ## file all the time when switching between configurations, don't declare ## crypto_config.h as a dependency. Remove this file from your working tree ## if you've just added or removed an option in crypto_config.h. -#generated_psa_test_data: ../include/psa/crypto_config.h -generated_psa_test_data: ../include/psa/crypto_values.h -generated_psa_test_data: ../include/psa/crypto_extra.h +#generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_config.h +generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_values.h +generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_extra.h generated_psa_test_data: suites/test_suite_psa_crypto_metadata.data generated_psa_test_data: echo " Gen $(GENERATED_PSA_DATA_FILES) ..." @@ -206,6 +206,8 @@ test: check # Generate variants of some headers for testing include/alt-extra/%_alt.h: ../include/%.h perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@ +include/alt-extra/%_alt.h: ../tf-psa-crypto/include/%.h + perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@ # Generate test library @@ -254,7 +256,7 @@ libtestdriver1.a: cp ./libtestdriver1/library/libmbedcrypto.a ../library/libtestdriver1.a ifdef RECORD_PSA_STATUS_COVERAGE_LOG -include/test/instrument_record_status.h: ../include/psa/crypto.h Makefile +include/test/instrument_record_status.h: ../tf-psa-crypto/include/psa/crypto.h Makefile echo " Gen $@" - sed <../include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p' + sed <../tf-psa-crypto/include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p' endif diff --git a/tests/psa-client-server/psasim/Makefile b/tests/psa-client-server/psasim/Makefile index 06d3059b4b..093f3b92c7 100644 --- a/tests/psa-client-server/psasim/Makefile +++ b/tests/psa-client-server/psasim/Makefile @@ -10,7 +10,7 @@ LIBPSACLIENT := -Llibpsaclient/ -lmbedcrypto -lmbedx509 -lmbedtls LIBPSASERVER := -Llibpsaserver/ -lmbedcrypto MBEDTLS_ROOT_PATH = ../../.. -COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include +COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include TEST_BIN = test/psa_client \ test/psa_partition