Skip to content

Complete the move of driver wrappers to the dispatch/ directory#809

Open
asmellby wants to merge 15 commits into
Mbed-TLS:developmentfrom
asmellby:feature/dispatch-library
Open

Complete the move of driver wrappers to the dispatch/ directory#809
asmellby wants to merge 15 commits into
Mbed-TLS:developmentfrom
asmellby:feature/dispatch-library

Conversation

@asmellby

@asmellby asmellby commented Jun 11, 2026

Copy link
Copy Markdown

Description

The TF-PSA-Crypto 1.1 release introduced a dispatch directory with the following description:

A new directory dispatch has been added at the root of the repository
to eventually host all code that dispatches cryptographic operations to
drivers, such as psa_crypto_driver_wrappers_no_static.c. For the time
being, it only contains psa_crypto_driver_wrappers_no_static.h.

This PR completes the move of generated driver wrapper files and API headers to the dispatch directory.

PR checklist

Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.

@asmellby asmellby marked this pull request as ready for review June 11, 2026 11:58
@gilles-peskine-arm gilles-peskine-arm added size-s Estimated task size: small (~2d) needs-review Every commit must be reviewed by at least two team members needs-reviewer This PR needs someone to pick it up for review priority-high High priority - will be reviewed soon labels Jun 11, 2026
@gilles-peskine-arm gilles-peskine-arm removed the needs-reviewer This PR needs someone to pick it up for review label Jun 11, 2026

@gilles-peskine-arm gilles-peskine-arm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is moving in the direction we want, thanks. But I've asked Ronald to review as well, as he's the architect of the directory structure and build scripts. We're currently focusing on some security fixes for our next release, so it might be a while before he can review.

I'm not sure what users are supposed to be able to do. Whatever it is, it needs to be documented and tested.

I reviewed 56449b8

Comment thread core/CMakeLists.txt
Comment thread CMakeLists.txt
Comment thread CMakeLists.txt
set(TF_PSA_CRYPTO_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}/dispatch)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From prior experience, I think CMakeLists.txt in Mbed TLS will need to know about the new location to populate TF_PSA_CRYPTO_PRIVATE_INCLUDE_DIRS. It isn't properly extracting the information from TF-PSA-Crypto.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread CMakeLists.txt Outdated
Comment thread dispatch/CMakeLists.txt Outdated
Comment thread dispatch/include/psa/crypto_driver_contexts_composites.h
asmellby added 5 commits June 12, 2026 10:55
Allow supplying a custom dispatch directory using the
TF_PSA_CRYPTO_DISPATCH_DIR variable.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Use the dispatch directory for all driver wrapper files.
When file generation is enabled, generate into a dispatch/
build directory. Move the generation logic into the dispatch
CMakeLists.txt.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The dispatch/include/ directory is added as a public include
directory to contain dispatch and driver-specific include files.
It is currently empty.

In the installed CMake package, the new directory is collapsed
into the existing structure to maintain backward compatibility.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The crypto driver context headers are tightly coupled with the
dispatch implementation. Move them to the dispatch include
directory.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
@asmellby asmellby force-pushed the feature/dispatch-library branch from 56449b8 to e22eb7b Compare June 12, 2026 09:52
asmellby added 6 commits June 12, 2026 13:24
Let the generated files directly be part of the dispatch target
instead of using an intermediate custom target. Directly link
drivers with the dispatch target, using the correct flavor for
static and shared libraries.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Set the dispatch build directory explicitly to support out-of-tree
dispatch directories.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Add a testcase for the use of TF_PSA_CRYPTO_DISPATCH_DIR to
set a custom dispatch directory. The custom dispatch in the
testcase is created by copying and generating the vanilla
dispatch implementation into the test program directory.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Add a testcase for the use of TF_PSA_CRYPTO_DISPATCH_DIR to
set a custom dispatch directory when building and installing
a CMake package for TF-PSA-Crypto. The custom dispatch in the
testcase is created by copying and generating the vanilla
dispatch implementation into the test program directory.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Document the new include path and TF_PSA_CRYPTO_DISPATCH_DIR.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Simplify check for the new dispatch location and add new location
to check_names.py

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>

@gilles-peskine-arm gilles-peskine-arm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, except I'd like one point clarified in the documentation. I don't know much about CMake, so my review of CMake code is superficial.

Our CI appears to be stuck today (ticket filed), so results might not be available until Monday.

Comment thread CMakeLists.txt Outdated
# calling CMake in order to avoid target name clashes, via the use of
# TF_PSA_CRYPTO_TARGET_PREFIX. The value of this variable is prefixed to the
# tfpsacrypto and tfpsacrypto-apidoc targets.
# - TF_PSA_CRYPTO_DISPATCH_DIR: If set, this directory is used instead of the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please state that this must be an absolute path.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@gilles-peskine-arm gilles-peskine-arm added the needs-ci Needs to pass CI tests label Jun 12, 2026
@gilles-peskine-arm

Copy link
Copy Markdown
Contributor

Note that the CI isn't happy. There's at least a missing include directory in CMake builds.

asmellby added 4 commits June 18, 2026 15:01
Remove exclusion of driver wrappers from check_names.py

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Make it explicit that this option should be an absolute path.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The dispatch include dir was missing from the doxyfile and
from the config check test.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Some test cases (tf_psa_crypto_test_memsan_constant_flow_psa) rely on
reusing a generated version of the driver wrapper from a previous
CMake invocation. If the driver wrapper doesn't exist in the source
directory but does exist in the build directory, use the file from
the build directory.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci Needs to pass CI tests needs-work priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)

Projects

Development

Successfully merging this pull request may close these issues.

2 participants