Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ endif()
# Set the project and framework root directory.
set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(MBEDTLS_FRAMEWORK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/framework)
if(NOT DEFINED TF_PSA_CRYPTO_DISPATCH_DIR)
set(TF_PSA_CRYPTO_DISPATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/dispatch)
endif()

option(ENABLE_PROGRAMS "Build Mbed TLS programs." ON)

Expand Down Expand Up @@ -380,7 +383,7 @@ endforeach(target)
#
set(TF_PSA_CRYPTO_PRIVATE_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/core
${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/dispatch
${TF_PSA_CRYPTO_DISPATCH_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/drivers/builtin/src
${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/extras
${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/platform
Expand Down Expand Up @@ -434,6 +437,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
tests/include
include
tf-psa-crypto/include
${TF_PSA_CRYPTO_DISPATCH_DIR}/include
tf-psa-crypto/drivers/builtin/include
tf-psa-crypto/drivers/everest/include
tf-psa-crypto/drivers/pqcp/include
Expand Down Expand Up @@ -471,6 +475,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
tests/include
include
tf-psa-crypto/include
${TF_PSA_CRYPTO_DISPATCH_DIR}/include
tf-psa-crypto/drivers/builtin/include
library
tf-psa-crypto/drivers/everest/include
Expand Down
4 changes: 2 additions & 2 deletions doxygen/mbedtls.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
CASE_SENSE_NAMES = NO
INPUT = ../include input ../tf-psa-crypto/include ../tests/include/alt-dummy
INPUT = ../include input ../tf-psa-crypto/include ../tf-psa-crypto/dispatch/include ../tests/include/alt-dummy
FILE_PATTERNS = *.h
EXCLUDE = ../tf-psa-crypto/include/mbedtls/private
RECURSIVE = YES
Expand All @@ -22,7 +22,7 @@ GENERATE_LATEX = NO
GENERATE_XML = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
INCLUDE_PATH = ../include ../tf-psa-crypto/include ../tf-psa-crypto/drivers/builtin/include
INCLUDE_PATH = ../include ../tf-psa-crypto/include ../tf-psa-crypto/dispatch/include ../tf-psa-crypto/drivers/builtin/include
EXPAND_AS_DEFINED = MBEDTLS_PRIVATE
CLASS_DIAGRAMS = NO
HAVE_DOT = YES
Expand Down
8 changes: 5 additions & 3 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ endif(USE_SHARED_MBEDTLS_LIBRARY)

foreach(target IN LISTS target_libraries)
add_library(MbedTLS::${target} ALIAS ${target}) # add_subdirectory support
# Include public header files from /include, /tf-psa-crypto/include/ and
# tf-psa-crypto/drivers/builtin/include/. Include private header files
# from /library and ${TF_PSA_CRYPTO_PRIVATE_INCLUDE_DIRS}.
# Include public header files from /include, /tf-psa-crypto/include,
# /tf-psa-crypto/dispatch/include and /tf-psa-crypto/drivers/builtin/include.
# Include private header files from /library and
# ${TF_PSA_CRYPTO_PRIVATE_INCLUDE_DIRS}.
target_include_directories(${target}
PUBLIC $<BUILD_INTERFACE:${MBEDTLS_DIR}/include/>
$<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/include/>
$<BUILD_INTERFACE:${MBEDTLS_DIR}/tf-psa-crypto/drivers/builtin/include/>
$<BUILD_INTERFACE:${TF_PSA_CRYPTO_DISPATCH_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${MBEDTLS_DIR}/library/
${TF_PSA_CRYPTO_PRIVATE_INCLUDE_DIRS}
Expand Down
6 changes: 4 additions & 2 deletions programs/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ if(TEST_CPP)
target_include_directories(cpp_dummy_build
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/drivers/builtin/include)
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/drivers/builtin/include
PRIVATE ${TF_PSA_CRYPTO_DISPATCH_DIR}/include)
target_link_libraries(cpp_dummy_build ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
endif()

Expand All @@ -39,7 +40,8 @@ if(USE_SHARED_MBEDTLS_LIBRARY AND
target_include_directories(dlopen
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/drivers/builtin/include)
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/drivers/builtin/include
PRIVATE ${TF_PSA_CRYPTO_DISPATCH_DIR}/include)
target_link_libraries(dlopen ${CMAKE_DL_LIBS})
endif()

Expand Down
5 changes: 5 additions & 0 deletions programs/test/cmake_subproject_custom_dispatch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
custom/include
custom/psa_crypto_driver_wrappers*
Makefile
cmake_subproject_custom_dispatch
22 changes: 22 additions & 0 deletions programs/test/cmake_subproject_custom_dispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.5.1)

# Test the target renaming support by adding a prefix to the targets built
set(MBEDTLS_TARGET_PREFIX subproject_test_)

# We use the parent Mbed TLS directory as the MBEDTLS_DIR for this test. Other
# projects that use Mbed TLS as a subproject are likely to add by their own
# relative paths.
set(MBEDTLS_DIR ../../../)
# Use the local `custom` directory for the crypto dispatch implementation
set(TF_PSA_CRYPTO_DISPATCH_DIR ${CMAKE_CURRENT_LIST_DIR}/custom)

# Add Mbed TLS as a subdirectory.
add_subdirectory(${MBEDTLS_DIR} build)

add_executable(cmake_subproject_custom_dispatch cmake_subproject_dispatch.c)
target_link_libraries(cmake_subproject_custom_dispatch
subproject_test_mbedtls
subproject_test_mbedx509
subproject_test_tfpsacrypto
${CMAKE_THREAD_LIBS_INIT}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Simple program to test that CMake builds with Mbed TLS as a subdirectory
* work correctly.
*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/

#include "mbedtls/build_info.h"

#include "mbedtls/platform.h"

#include "mbedtls/version.h"

/* Verify that the dispatch implementation is the custom one by linking with
* a nonstandard symbol. Real custom dispatch implementations should not have
* nonstandard symbols. */
int verify_custom_dispatch(void);

/* The main reason to build this is for testing the CMake build, so the program
* doesn't need to do very much. It calls a single library function to ensure
* linkage works, but that is all. */
int main()
{
const char *version = mbedtls_version_get_string_full();

mbedtls_printf("Built against %s\n", version);

return verify_custom_dispatch();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
list(APPEND dispatch_src_files
"${CMAKE_CURRENT_SOURCE_DIR}/custom_dispatch.c"
"${CMAKE_CURRENT_SOURCE_DIR}/psa_crypto_driver_wrappers_no_static.c"
)

set(tf_psa_crypto_objlib "dispatch")
include(${PROJECT_SOURCE_DIR}/objlib.cmake)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Dummy function to verify custom dispatch implementation
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/

int verify_custom_dispatch(void);
int verify_custom_dispatch(void)
{
return 0;
}
1 change: 1 addition & 0 deletions scripts/generate_query_config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
my @header_roots = qw(
include
tf-psa-crypto/include
tf-psa-crypto/dispatch/include
tf-psa-crypto/drivers/builtin/include
);
for my $root (@header_roots) {
Expand Down
3 changes: 3 additions & 0 deletions scripts/legacy.make
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ install: no_test
cp -rp tf-psa-crypto/drivers/builtin/include/mbedtls $(DESTDIR)/include
mkdir -p $(DESTDIR)/include/psa
cp -rp tf-psa-crypto/include/psa $(DESTDIR)/include
cp -rp tf-psa-crypto/dispatch/include/psa $(DESTDIR)/include

mkdir -p $(DESTDIR)/lib
cp -RP library/libmbedtls.* $(DESTDIR)/lib
Expand Down Expand Up @@ -172,6 +173,7 @@ C_SOURCE_FILES = $(wildcard \
library/*.[hc] \
tf-psa-crypto/core/*.[hc] \
tf-psa-crypto/include/*/*.h \
tf-psa-crypto/dispatch/include/*/*.h \
tf-psa-crypto/drivers/*/include/*/*.h \
tf-psa-crypto/drivers/*/include/*/*/*.h \
tf-psa-crypto/drivers/*/include/*/*/*/*.h \
Expand Down Expand Up @@ -203,6 +205,7 @@ cscope: cscope.in.out cscope.po.out cscope.out
cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
cscope -bq -u -Iinclude -Ilibrary -Itf-psa-crypto/core \
-Itf-psa-crypto/include \
-Itf-psa-crypto/dispatch/include \
-Itf-psa-crypto/drivers/builtin/src \
-Itf-psa-crypto/dispatch \
-Itf-psa-crypto/extras \
Expand Down
23 changes: 23 additions & 0 deletions tests/scripts/components-build-system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ support_test_cmake_as_subdirectory () {
support_test_cmake_out_of_source
}

component_test_cmake_as_subdirectory_custom_dispatch () {
# Remove existing generated files so that we use the ones CMake
# generates
$MAKE_COMMAND neat

msg "build: custom dispatch with cmake 'as-subdirectory' build"
cp -r tf-psa-crypto/dispatch/include programs/test/cmake_subproject_custom_dispatch/custom
cp tf-psa-crypto/dispatch/psa_crypto_driver_wrappers_no_static.h programs/test/cmake_subproject_custom_dispatch/custom
mv tf-psa-crypto/dispatch tf-psa-crypto/dispatch.bak
tf-psa-crypto/scripts/generate_driver_wrappers.py programs/test/cmake_subproject_custom_dispatch/custom
cd programs/test/cmake_subproject_custom_dispatch
# Note: Explicitly generate files as these are turned off in releases
cmake -D GEN_FILES=ON .
make
./cmake_subproject_custom_dispatch
cd ../../..
mv tf-psa-crypto/dispatch.bak tf-psa-crypto/dispatch
}

support_test_cmake_as_subdirectory_custom_dispatch () {
support_test_cmake_out_of_source
}

component_test_cmake_as_package () {
# Remove existing generated files so that we use the ones CMake
# generates
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def _consistency_check(self):
header += f'#error "{option}"\n'
header += '#endif\n'
include_path = ['include', 'tf-psa-crypto/include',
'tf-psa-crypto/dispatch/include',
'tf-psa-crypto/drivers/builtin/include']

try:
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/test_config_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MbedtlsTestConfigChecks(unittest_config_checks.TestConfigChecks):
PROJECT_CONFIG_C = 'library/mbedtls_config.c'
PROJECT_SPECIFIC_INCLUDE_DIRECTORIES = [
'tf-psa-crypto/include',
'tf-psa-crypto/dispatch/include',
'tf-psa-crypto/drivers/builtin/include',
]

Expand Down
2 changes: 1 addition & 1 deletion tf-psa-crypto
Submodule tf-psa-crypto updated 59 files
+20 −5 CMakeLists.txt
+13 −0 ChangeLog.d/dispatch-split.txt
+3 −0 ChangeLog.d/doxygen-build-folder.txt
+3 −0 ChangeLog.d/issue784.txt
+2 −2 README.md
+2 −2 SECURITY.md
+0 −2 core/.gitignore
+1 −30 core/CMakeLists.txt
+8 −8 core/crypto-library.make
+2 −0 core/tf_psa_crypto_config.c
+4 −0 dispatch/.gitignore
+52 −0 dispatch/CMakeLists.txt
+25 −0 dispatch/include/psa/crypto_driver_contexts_composites.h
+0 −0 dispatch/include/psa/crypto_driver_contexts_key_derivation.h
+0 −0 dispatch/include/psa/crypto_driver_contexts_primitives.h
+3 −3 doxygen/tfpsacrypto.doxyfile.in
+9 −3 drivers/CMakeLists.txt
+9 −0 drivers/builtin/include/mbedtls/private/crypto_builtin_composites.h
+1 −0 drivers/driver.cmake
+2 −1 drivers/p256-m/CMakeLists.txt
+28 −1 drivers/pqcp/include/tf-psa-crypto/private/crypto_struct_pqcp.h
+340 −8 drivers/pqcp/src/psa_crypto_mldsa.c
+161 −4 drivers/pqcp/src/psa_crypto_mldsa.h
+2 −2 drivers/pqcp/src/wrap_mldsa_native.c
+1 −1 framework
+83 −0 include/psa/crypto.h
+52 −8 include/psa/crypto_struct.h
+1 −0 objlib.cmake
+6 −0 programs/test/cmake_package_install_custom_dispatch/.gitignore
+41 −0 programs/test/cmake_package_install_custom_dispatch/CMakeLists.txt
+24 −0 programs/test/cmake_package_install_custom_dispatch/cmake_package_install_dispatch.c
+13 −0 programs/test/cmake_package_install_custom_dispatch/custom/CMakeLists.txt
+13 −0 programs/test/cmake_package_install_custom_dispatch/custom/custom_dispatch.c
+5 −0 programs/test/cmake_subproject_custom_dispatch/.gitignore
+24 −0 programs/test/cmake_subproject_custom_dispatch/CMakeLists.txt
+24 −0 programs/test/cmake_subproject_custom_dispatch/cmake_subproject_dispatch.c
+7 −0 programs/test/cmake_subproject_custom_dispatch/custom/CMakeLists.txt
+13 −0 programs/test/cmake_subproject_custom_dispatch/custom/custom_dispatch.c
+0 −0 programs/test/cmake_subproject_custom_dispatch/framework/.gitignore
+3 −1 scripts/crypto-common.make
+6 −1 scripts/data_files/driver_jsons/driverlist.json
+23 −0 scripts/data_files/driver_jsons/pqcp_driver.json
+442 −0 scripts/data_files/driver_templates/psa_crypto_driver_wrappers.h.jinja
+2 −2 scripts/generate_driver_wrappers.py
+2 −2 scripts/maintainer/generate_mldsa_tests.py
+17 −0 scripts/project_knowledge/__init__.py
+37 −0 scripts/project_knowledge/tf_psa_crypto_test_case_info.py
+17 −1 tests/scripts/analyze_outcomes.py
+24 −0 tests/scripts/components-build-system.sh
+2 −0 tests/scripts/test_config_checks.py
+8 −29 tests/scripts/tf_psa_crypto_test_case_info.py
+72 −0 tests/suites/test_suite_config.crypto_combinations.data
+188 −0 tests/suites/test_suite_dispatch_transparent.dilithium_py.data
+243 −0 tests/suites/test_suite_dispatch_transparent.function
+95 −0 tests/suites/test_suite_dispatch_transparent.mldsa_multipart.data
+12 −0 tests/suites/test_suite_dispatch_transparent.sign.data
+188 −0 tests/suites/test_suite_psa_crypto_mldsa.dilithium_py.data
+243 −0 tests/suites/test_suite_psa_crypto_mldsa.function
+95 −0 tests/suites/test_suite_psa_crypto_mldsa.multipart.data