-
Notifications
You must be signed in to change notification settings - Fork 2.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
Support volatile keys in external SE #3382
Support volatile keys in external SE #3382
Conversation
Thanks @stevew817 for the PR. This doesn't build in some configs, e.g.
|
Interesting. I'm running with tests/scripts/basic-in-docker.sh, which does not throw this error. Is this script somehow only testing a previous version, and not updating with the latest in the working directory? Is there some script that needs to be run before it to get it to regenerate the output of the .function and .data files? |
You can pass component names ( |
b062248
to
68e9556
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.
Overall this mostly looks good, but a few areas need work.
The CI results aren't very useful right now because builds without SE support break on p_drv
being unused in psa_start_key_creation
.
library/psa_crypto.c
Outdated
|
||
if( attributes->core.lifetime != PSA_KEY_LIFETIME_VOLATILE ) | ||
/* Check there is a proper handler for this lifetime */ | ||
if ( PSA_KEY_LIFETIME_GET_LOCATION( lifetime ) |
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.
The code for persistent/volatile and local/external should be mostly orthogonal. As it stands, some validation is missing on persistent SE keys.
If MBEDTLS_PSA_CRYPTO_SE_C
is enabled and MBEDTLS_PSA_CRYPTO_STORAGE_C
is disabled, a persistent external key should be rejected. This configuration is currently rejected in check_config.h
, but only because there is currently no support for volatile external keys, which this PR changes.
To keep this PR small, it's ok to keep the restriction in check_config.h
and do the following later:
- Remove the restriction in
check_config.h
. - In
all.sh
, no longer systematically disableMBEDTLS_PSA_CRYPTO_SE_C
whenMBEDTLS_PSA_CRYPTO_STORAGE_C
is disabled. - Fix any failing test.
But please fix the existing bug that the key id isn't validated for keys in a secure element and add a non-regression test.
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.
Is there any intent to support persistent SE-stored keys without having to require PSA Crypto Storage?
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.
No, because the metadata is always in internal storage. Due to the interface design (the application only remembers the key id, not its lifetime), it's difficult to have metadata spread over multiple storage areas.
169de02
to
3561551
Compare
Sorry I forgot to mention this earlier, but for future reference, please don't mark GitHub conversations as resolved when you're the author of the code: that's for the commenter to do when they've decided that the comment was resolved satisfactorily. In Mbed TLS, we have a convention for the coder use the 🚀 emoji to indicate “I've handled this comment in my local copy”, if you want to keep track of which comments you've handled. |
@gilles-peskine-arm Do you have insight into why those two CI jobs are still failing? |
The remaining CI failure is from the ABI compatibility checker. It says that the symbol So that's a pass from CI. I'll review shortly. |
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'm happy with the library code and with the tests. The documentation needs a little improvement.
The commit history is hard to follow, so I'm requesting a rewrite of the history. The commits “Update PSA core to not persist SE keys declared volatile” and “Fixups after review” do too many things. Please break them up. At this point, you might as well remove the back-and-forth between these two commits. In general, please don't do mix refactoring and adding new things in the same commit.
And please use more descriptive commit messages. For example, “Enable figuring out number of cores when running on OS X” is a good commit message: it explains exactly what's going on. “Fix error from #3302” is not so good; it's acceptable because the diff is very simple, but “Fix typo in a macro that isn't used yet” would be more informative. “Update PSA core to not persist SE keys declared volatile” is not bad in itself but the commit does too much which isn't described in the commit message. “Simplify key checking” lacks explanations and “Fixups after review” is not informative at all.
Please add a changelog entry in ChangeLog.d
.
To facilitate review, please save a copy of the current state in your fork (I use the naming convention original-branch-name-1
, original-branch-name-2
, etc. for successive versions) before force-pushing. Please avoid combining new content with a force-push that rewrites the history. Also, please don't rebase on top of the current target branch if there's no strong reason for it (like a force push). The reason for these requests is to make the force-push diff easy to review (in particular, if you're only restructuring commits or rewriting commit messages, the force-push diff should be empty).
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
3561551
to
62ec1d4
Compare
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
bd95312
to
14b8184
Compare
Force-push updated commit message length as requested by @ronald-cron-arm |
Inline with review comments. Signed-off-by: Steven Cooreman <[email protected]>
Signed-off-by: Steven Cooreman <[email protected]>
@gilles-peskine-arm again, all failing CI is inside the ARM network and I cannot see what would've cause failure. |
The CI failures seem mainly to be in our Mbed OS testing:
However, I don't know enough about this change or that testing to suggest what the problem is. There's also the ABI/API compatibility check failure, which Gilles said earlier can be ignored. |
Mbed OS Testing is currently broken thus just ignore it. Sorry for the inconvenience. Thus this PR does not have any CI issues currently. |
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.
Thank you for addressing my comments. LGTM.
CI passed except for:
So this is as good as a pass. |
return( PSA_SUCCESS ); | ||
|
||
if( psa_is_key_id_valid( key_id, | ||
psa_key_lifetime_is_external( lifetime ) ) ) |
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.
Sorry for missing this at the time, but psa_key_lifetime_is_external
is wrong here. This allows any application to create a key with a key id that's reserved for the implementation, as long as the key is in a secure element. This wasn't a big issue at the time of this pull request because Mbed TLS didn't use the implementation key id range. But with #3547 (comment) it's beginning to use the range and we're going to have to backtrack this change.
Description
Implemented changes requested in #3288 to support volatile keys located in Secure Element drivers, and to not have the PSA core store information about those volatile keys persistently.
Status
READY
Requires Backporting
NO
Migrations
NO
Additional comments
Todos
Steps to test or reproduce
Tested through the updated SE HAL test suite.