-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgmt: mcumgr: replace Tinycrypt by PSA #71947
mgmt: mcumgr: replace Tinycrypt by PSA #71947
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot accept this change. I understand that having multiple security backends is not great, but when I enable the existing tinycrypt mode for this feature, I get:
Memory region Used Size Region Size %age Used
FLASH: 208648 B 472 KB 43.17%
RAM: 61280 B 256 KB 23.38%
IDT_LIST: 0 GB 32 KB 0.00%
When I switch over to mbedtls I get:
Memory region Used Size Region Size %age Used
FLASH: 219436 B 472 KB 45.40%
RAM: 61280 B 256 KB 23.38%
IDT_LIST: 0 GB 32 KB 0.00%
This is an increase of 10.6KiB, for a simple sha256 hash. I don't know what the overhead of this is in tfm but the overhead without is not acceptable
Would it be an option to compile this conditionally? i.e. by default mcumgr would use PSA APIs, since that is the direction the project has chosen, but with Kconfig one could still enable Tinycrypt. |
In my opinion it could definitely be. |
+1 |
@nordicjm what is the target / configuration you tested it ? 10k is really too much, I have seen this building
But lets not jump into early conclusions, I have just disabled some additional features that were enabled by default when building with mbedTLS and the difference was way smaller. Before any change (building with mbedTLS):
After disable unnecessary options for this test:
Without these changes (current upstream)
I don't think supporting TinyCrypt indefinitely is a proper solution (obviously, we don't want to be disruptive in a LTS release). We need to have a proper solution. I understand the concern with additional resources needed, but there are also multiple benefits adopting it. |
Tinycrypt itself I'm not so bothered about, the 10KiB jump is what I'm bothered about. In tinycrypt you enable it then have to enable what features you want, seemingly in mbedtls you enable it then have to go and disable features you don't want, that's not really useful and certainly not what other Kconfigs in zephyr subsystems do, you enable a feature with a set of minimal defaults then enable the additional ones you want, so if the size difference from that can be vastly reduced by having minimal defaults and a way for features to select what they need e.g. SHA256 which enables them then that's a path on the right track |
Build string:
|
I agree with you, it is non-sense pulling a bunch of functionalities that were not requested. My comment was to address the size increase issue. There will much likely be an increase with PSA but that must not be in this magnitude. |
f366bd3
to
a3c71b1
Compare
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
a3c71b1
to
f64f1aa
Compare
With the changes from #72078 that removes the default enabling of hash algorithms for MbedTLS, we get to the following differences when building TinyCrypt (reference):
MbedTLS (+480 bytes):
And when using directly MbedTLS (+68 bytes):
Additionally, if compiling with Now, regarding the PSA case. As of now the PSA API will only be used when building with TF-M, in which case the crypto operations happen in TF-M. Because TF-M already has the code, the net difference in code size when going from TinyCrypt to PSA is negative. Building with TinyCrypt (reference):
PSA (-768 bytes):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
It is meant specifically for configuration of the PSA crypto library. The underlying PSA configuration items are guarded by the condition that a PSA crypto provider must be present, which is the case when either TF-M is in use or MbedTLS's PSA core is built as part of the application image. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Exclude two more platforms from the tests. They provoke devicetree-related build errors which weren't introduced by the changes in this PR (zephyrproject-rtos#71947). Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
9b8fe02
to
500b25c
Compare
Rebased and resolved conflicts. |
Exclude two more platforms from the tests. They provoke devicetree-related build errors which weren't introduced by the changes in this PR (zephyrproject-rtos#71947). Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
500b25c
to
4341b58
Compare
As part of ongoing work to move away from TinyCrypt and towards PSA (zephyrproject-rtos#43712), make fs_mgmt use either PSA (when available) or MbedTLS (as a fallback) for SHA-256. The use of PSA is guarded by CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT which requires a locally-built PSA core for devices without TF-M. Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Exclude two more platforms from the tests. They provoke devicetree-related build errors which weren't introduced by the changes in this PR (zephyrproject-rtos#71947). Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
4341b58
to
bf4a226
Compare
Exclude some more platforms from the tests. They provoke devicetree-related build errors which weren't introduced by the changes in this PR (zephyrproject-rtos#71947). Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
bf4a226
to
fc67ac8
Compare
All CI failures should be addressed now. |
Exclude some more platforms from the tests. They provoke devicetree-related build errors which weren't introduced by the changes in this PR (zephyrproject-rtos#71947). Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
As part of ongoing work to move away from TinyCrypt and towards PSA (#43712), make
fs_mgmt
use either PSA (when available) or MbedTLS (as a fallback) for SHA-256.The use of PSA is guarded by CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT which requires a locally-built PSA core for devices without TF-M.