-
Notifications
You must be signed in to change notification settings - Fork 52
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
Allow the use of PSA Crypto in TLS client example #232
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this should come after
mbedtls_platform_setup()
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.
@RonEld Why?
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.
because
mbedtls_platform_setup()
initializes the hw acceleration engine, and itpsa_init()
is dependent on the driver, then it should come after.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.
In addition, if
psa_init()
is also intended to initialize the hw acceleration, then there could be conflicts, and undefined behaviourThere 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.
Perhaps the best location of calling
psa_init()
is withinmbedtls_platform_setup()
inmbed_platform_setup()
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.
Yes, it's a standalone library.
However,
mbedtls_platform_setup()
was first and foremost intended to initialize the HW acceleration engine.psa_crypto_init()
may need that engine.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.
@RonEld Sorry, I could only repeat what I just said. There must not be any dependency of
psa_crypto_init()
on Mbed TLS, in particular onmbedtls_platform_setup()
. If that's the case at the moment, it's a bug. In that case, I'm ok swapping the calls and opening a separate issue for it.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.
Correct, there shouldn't be a dependency between PSA crypto and Mbed TLS. however, there is a dependency between PSA crypto and the platform HW accelerators. At the moment, the HW accelerators are initialized by
mbedtls_platform_setup()
(currently only in NRF52840_Dk target on Mbed OS), so if the hw accelerator will be initialized also inpsa_crypto_init()
(as it probably should), there could be some resource leak or undefined behavior if initializing twice the cryptographic engine.To be honest, platforms that initialize the hw crypto engine in
mbedtls_platform_setup()
, don't support psa crypto, and once they migrate to psa crypto, they should remove the initialization in thembedtls_platform_xxx()
API.mbedtls_platform_setup()
was intended to initialize the hw acceleration engine, so actually it can't really co exist with `psa_crypto_init(). This is why I think my suggestion in #232 (comment) should probably be usedThere 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.
@RonEld Omitting
mbedtls_platform_setup()
ifMBEDTLS_USE_PSA_CRYPTO
is defined doesn't work because the function might perform other platform initialization tasks not related to PSA crypto. Are you ok letting this rest until ARMmbed/mbed-crypto#24 is settled?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.
At the moment, there are no other platform initialization tasks done in Mbed OS. The first intent for the platform initialization functions were to initialize hw acceleration. In the future it may be considered for other initialization (assuming it won't get deprecated), after the psa crypto will be fully integrated.
I will approve for the time being