-
Notifications
You must be signed in to change notification settings - Fork 7k
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
secure_storage: re-add MbedTLS backend #85840
Conversation
b6377c5
to
ef7d883
Compare
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 only left a minor comment/suggestion for not increasing the mess in config-tls-generic.h
further.
@@ -486,6 +486,11 @@ | |||
#define MBEDTLS_PSA_CRYPTO_STORAGE_C | |||
#endif | |||
|
|||
#if defined(CONFIG_SECURE_STORAGE_ITS_IMPLEMENTATION_MBEDTLS) |
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.
Question: can't we make a new Mbed TLS specific Kconfig to be used as guard here instead of using a secure-storage one? Something like CONFIG_MBEDTLS_ITS_FILE
or similar for example.
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.
Of course we could, but that symbol would just be:
config MBEDTLS_ITS_FILE
bool
default y if SECURE_STORAGE_ITS_IMPLEMENTATION_MBEDTLS
It just smears the definitions across more files.
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.
True, but then you would have secure-storage Kconfig enabling an Mbed TLS Kconfig which then "internally" sets the build symbols to build Mbed TLS. In other words, in this way we would keep relations between different subsystems/modules at Kconfig level. It just looks cleaner to me, but I guess it's a matter of preference, so I'll let the maintaner decide what to do.
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.
Happy to change the symbols if needed, but literally 2 lines above my change there is already a:
#if defined(CONFIG_SECURE_STORAGE)
#define MBEDTLS_PSA_CRYPTO_STORAGE_C
#endif
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.
Oh damn, that's right. Then I guess that it will take one or more specific PRs to fix all the mess in that header file, but that's out of scope for this one. Please ignore my comment and sorry for the noise.
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.
FYI I am changing that in #85735 (introducing CONFIG_MBEDTLS_PSA_CRYPTO_STORAGE_C
).
3fff58e
to
e464430
Compare
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.
@JordanYates, just FYI, that we faced using mbedtls posix backend. This is not thread safe. If you have multiple instances on your test PC all of them compete for the same file with keys. There are key ID collisions those misbehave test scenarios.
I created bug report about this: #59362 but seems this is not priority, and it was closed as Stale.
In mesh we had to use Zephyr backends in secure storage to not have this misbehavior.
Furthermore, we removed (and continue removing: #85069) all technological stubs to run Mesh bsim tests on native Zephyr secure storage backend to improve test coverage.
e464430
to
684b58a
Compare
Thats interesting. Wouldn't that also apply to the secure storage backend that uses the settings subsystem and the file backend? |
I'm not familiar with how the settings subsystem uses the file in form of backends. If this is not instantiated, then the issue is still possible. |
Re-add the option to use the MbedTLS ITS backend on posix. This backend is much simpler to setup than the Zephyr backends in a testing environment. This was previously removed in: zephyrproject-rtos#82319 Signed-off-by: Jordan Yates <[email protected]>
684b58a
to
d00adcb
Compare
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 don't know, this feels like a step backwards.
The Mbed TLS ITS implementation has never been part of the secure storage subsystem. It was a kludge for BT Mesh testing that only lived in the Mbed TLS configuration file.
What is the problem with using secure storage on POSIX exactly? As @alxelax said it improves test coverage. Going for the Mbed TLS ITS implementation comes with its own problems and basically circumvents the whole secure storage subsystem.
(On top of that, I don't see how this even works in practice. From what header file do you get your PSA ITS function prototypes? But anyway this is not the question here.)
@@ -486,6 +486,11 @@ | |||
#define MBEDTLS_PSA_CRYPTO_STORAGE_C | |||
#endif | |||
|
|||
#if defined(CONFIG_SECURE_STORAGE_ITS_IMPLEMENTATION_MBEDTLS) |
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.
FYI I am changing that in #85735 (introducing CONFIG_MBEDTLS_PSA_CRYPTO_STORAGE_C
).
The MbedTLS ITS implementation enables
Without the MbedTLS ITS implementation, that code snippets fails due to |
Yeah okay, it will allow you to use the ITS indirectly (through persistent keys in the PSA Crypto API) because Mbed TLS will use its internal
Of course zephyr/subsys/secure_storage/Kconfig.its_store Lines 20 to 21 in 45a54ba
|
That's fine, storing a root identity is critical to a lot of my tests, using ITS and PS functions is not.
Thats fine, but for a lot of tests it's an additional overlay file and options, when the MbedTLS ITS implementation does everything the test needs by itself. |
Perhaps an alternate path forward would be something along these lines?
|
Improved solution in #86184 |
Re-add the option to use the MbedTLS ITS backend on posix. This backend is much simpler to setup than the Zephyr backends in a testing environment. This was previously removed in: #82319