Skip to content

Conversation

Wer-Wolf
Copy link
Contributor

Contribution description

Currently PSA mac backends can only implement psa_mac_compute() from the PSA crypto API, but not psa_mac_verify() and the associated multi-part functions.

Extend the location and algorithm dispatchers to connect the above PSA API functions to suitable backends. Also extend the MAC backend API to allow backends to implement those additional functions. Due to a design issue with the SE backend API (context size is dynamic, thus requiring a memory allocation) only psa_mac_verify() can be accelerated by SE backends.

Currently no backend implements the additional functions, but this will change in the future.

Testing procedure

I successfully compiled and executed the PSA-related tests.

Issues/PRs references

Prerequisite for #20758.

@github-actions github-actions bot added Area: pkg Area: External package ports Area: sys Area: System labels Jul 23, 2025
@crasbe crasbe added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 23, 2025
@riot-ci
Copy link

riot-ci commented Jul 23, 2025

Murdock results

✔️ PASSED

27cf424 sys/psa_crypto: Extend mac API

Success Failures Total Runtime
10544 0 10546 10m:10s

Artifacts

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! Looks mostly good at a first glance, please see some comments below.

Due to a design issue with the SE backend API (context size is dynamic, thus requiring a memory allocation) only psa_mac_verify() can be accelerated by SE backends.

Could you further elaborate on this? It's fine to leave the SE backend untouched for now, but I'd like to understand the reasoning.

@Wer-Wolf
Copy link
Contributor Author

Thanks! Looks mostly good at a first glance, please see some comments below.

Due to a design issue with the SE backend API (context size is dynamic, thus requiring a memory allocation) only psa_mac_verify() can be accelerated by SE backends.

Could you further elaborate on this? It's fine to leave the SE backend untouched for now, but I'd like to understand the reasoning.

Currently the PSA MAC dispatcher can only know the context size required by the SE backend during runtime using the context_size field inside the associated struct. This means that psa_mac_operation_t cannot be statically sized and has to use dynamic memory allocation instead.

@Wer-Wolf Wer-Wolf force-pushed the psa-hmac-dispatch branch 2 times, most recently from 2df74ac to 273bec5 Compare July 29, 2025 15:23
Currently PSA mac backends can only implement psa_mac_compute() from
the PSA crypto API, but not psa_mac_verify() and the associated
multi-part functions.

Extend the location and algorithm dispatchers to connect the above
PSA API functions to suitable backends. Also extend the MAC backend
API to allow backends to implement those additional functions. Due
to a design issue with the SE backend API (context size is dynamic,
thus requiring a memory allocation) only psa_mac_verify() can be
accelerated by SE backends.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
@Wer-Wolf Wer-Wolf force-pushed the psa-hmac-dispatch branch from 273bec5 to 27cf424 Compare July 29, 2025 15:52
@mguetschow
Copy link
Contributor

Thanks! Looks mostly good at a first glance, please see some comments below.

Due to a design issue with the SE backend API (context size is dynamic, thus requiring a memory allocation) only psa_mac_verify() can be accelerated by SE backends.

Could you further elaborate on this? It's fine to leave the SE backend untouched for now, but I'd like to understand the reasoning.

Currently the PSA MAC dispatcher can only know the context size required by the SE backend during runtime using the context_size field inside the associated struct. This means that psa_mac_operation_t cannot be statically sized and has to use dynamic memory allocation instead.

Well this is solved in psa_cipher_operation_t by having a psa_se_cipher_context_t which contains a driver specific context in a union. This could probably be done the same way for psa_mac_operation_t, but is something for a follow-up PR as said.

@mguetschow mguetschow added this pull request to the merge queue Jul 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 30, 2025
@mguetschow
Copy link
Contributor

Hum, seems like Nordic is now checking for human users while downloading the SDK

https://www.nordicsemi.com/-/media/Software-and-other-downloads/SDKs/nRF5/Binaries/nRF5_SDK_17.1.0_ddde560.zip:
2025-07-30 09:46:37 ERROR 403: Forbidden.

Should we host the zip ourselves instead?

@Wer-Wolf
Copy link
Contributor Author

Does the license allow it?

@crasbe
Copy link
Contributor

crasbe commented Jul 31, 2025

Does the license allow it?

Copyright (c) 2010 - 2021, Nordic Semiconductor ASA

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form, except as embedded into a Nordic
   Semiconductor ASA integrated circuit in a product or a software update for
   such product, must reproduce the above copyright notice, this list of
   conditions and the following disclaimer in the documentation and/or other
   materials provided with the distribution.

3. Neither the name of Nordic Semiconductor ASA nor the names of its
   contributors may be used to endorse or promote products derived from this
   software without specific prior written permission.

4. This software, with or without modification, must only be used with a
   Nordic Semiconductor ASA integrated circuit.

5. Any software provided in binary form under this license must not be reverse
   engineered, decompiled, modified and/or disassembled.

THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Should be no issue.

@crasbe crasbe added this pull request to the merge queue Jul 31, 2025
Merged via the queue into RIOT-OS:master with commit 6b72096 Jul 31, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pkg Area: External package ports 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: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants