Skip to content

Conversation

Wer-Wolf
Copy link
Contributor

Contribution description

Currently the headers of the PSA crypto API are designed in a monolithic fashion: all types are defined in a single file, all
context structs are defined inside a single file, etc.

This however makes it impossible to build stacked PSA crypto backends. For example build a generic HMAC backend based upon the already existing hash backend is currently not possible do to incomplete type definitions when trying to define the necessary context struct.

This PR breaks up the monolithic headers into smaller ones that can be used by stacked backends without pulling in the other (possibly incomplete) type definitions. In the future this will make it possible to finally build a generic HMAC backend for the PSA crypto API.

Please note that this PR is still a draft since i was unable to test it on a board with a secure element. I was hoping that the CI service will do that.

Testing procedure

Since the PR only reorders header definitions no functional impacts are expected. However in order to avoid build failures i ran all PSA crypto tests inside the test/sys directory.

Issues/PRs references

This PR is a prerequisite for PR #20758.

@github-actions github-actions bot added Area: sys Area: System Area: examples Area: Example Applications labels May 27, 2025
@Wer-Wolf Wer-Wolf marked this pull request as draft May 27, 2025 16:05
@Wer-Wolf Wer-Wolf force-pushed the psa-hash-headers branch from 5530329 to edac353 Compare May 27, 2025 16:49
@mguetschow mguetschow added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 27, 2025
@riot-ci
Copy link

riot-ci commented May 27, 2025

Murdock results

✔️ PASSED

501811e sys/psa_crypto: Split subsystem definitions into separate files

Success Failures Total Runtime
10379 0 10379 10m:17s

Artifacts

@crasbe crasbe added the Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation label May 27, 2025
Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this! I still have some questions below.

@mguetschow
Copy link
Contributor

We've also got a merge conflict with #21455 merged in tonight.

@Wer-Wolf Wer-Wolf force-pushed the psa-hash-headers branch 2 times, most recently from 5026111 to 71f1a8e Compare June 9, 2025 16:27
@Wer-Wolf
Copy link
Contributor Author

Wer-Wolf commented Jun 9, 2025

We've also got a merge conflict with #21455 merged in tonight.

I just rebased this series onto the latest master branch and resolved any merge conflicts.

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

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

Thanks again for your work on this! LGTM now.

Please shorten the three failing commits messages to less than 72 characters and force-push. Let's get this finally done!

@Wer-Wolf
Copy link
Contributor Author

Would it be fine if i squash all/some commits together?

@mguetschow
Copy link
Contributor

Sure, whatever you see fit :)

Currently PSA backends cannot use other backends because the necessary
definitions are defined in a single big header file. This prevents us
from creating a generic HMAC backend based on the available hash
backends, as the hash context struct is not available when defining the
HMAC context struct.

Fix this by spliting the headers into separate files. This makes it
possible us use the hash context definitions without pulling in the
remaining context definitions.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
@Wer-Wolf
Copy link
Contributor Author

Are there any remaining issues?

@Teufelchen1 Teufelchen1 changed the title [DRAFT] PSA header rework PSA header rework Jun 24, 2025
@Teufelchen1 Teufelchen1 marked this pull request as ready for review June 24, 2025 10:36
@crasbe crasbe changed the title PSA header rework sys/psa_crypto: Rework Headers Jun 24, 2025
@mguetschow
Copy link
Contributor

No, this is ready to be merged! Thanks again for your work on this!

@mguetschow mguetschow added this pull request to the merge queue Jun 30, 2025
@Wer-Wolf
Copy link
Contributor Author

Nice, thank you.

Merged via the queue into RIOT-OS:master with commit 52db3b8 Jun 30, 2025
25 checks passed
@mguetschow
Copy link
Contributor

There we go, finally merged! 🎉 I hope this can unlock the work on the generic HMAC implementation in #20758 :)

@Wer-Wolf
Copy link
Contributor Author

I am already working on it.

@mguetschow mguetschow deleted the psa-hash-headers branch June 30, 2025 16:10
@Teufelchen1 Teufelchen1 added this to the Release 2025.07 milestone Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: examples Area: Example Applications Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants