-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/psa_crypto: Implement persistent key storage #20099
sys/psa_crypto: Implement persistent key storage #20099
Conversation
4003957
to
29f2020
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.
Nice job, thank you! 🎉
I've finally taken the time to do a partial review (excluding the test applications and without actually running the code). A few first comments below.
sys/psa_crypto/psa_persistent_storage/psa_crypto_cbor_encoder.c
Outdated
Show resolved
Hide resolved
sys/psa_crypto/psa_persistent_storage/psa_crypto_persistent_storage.c
Outdated
Show resolved
Hide resolved
sys/psa_crypto/psa_persistent_storage/psa_crypto_persistent_storage.c
Outdated
Show resolved
Hide resolved
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.
Some more comments below on the tests. Thanks again for your work!
tests/sys/psa_crypto_persistent_storage/tests_psa_persistent_storage.h
Outdated
Show resolved
Hide resolved
tests/sys/psa_crypto_persistent_storage/test_psa_crypto_store_persistent_single_key.c
Outdated
Show resolved
Hide resolved
tests/sys/psa_crypto_persistent_storage/test_psa_crypto_store_persistent_single_key.c
Show resolved
Hide resolved
tests/sys/psa_crypto_persistent_storage/test_psa_crypto_store_persistent_asym_keypair.c
Outdated
Show resolved
Hide resolved
@mguetschow thank you for the nice and detailed feedback! I didn't finish everything today, but I'm working on it =) |
Two more things I thought about:
|
29f2020
to
74f2b9a
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.
Thanks for adapting to my feedback. The CBOR format and code is much more concise now, I like!
Second round of review below. It's quite an extensive PR, so I'd expect some more.
Just a small comment: Could you maybe avoid rebasing before pushing the changes so that Github can show me a nice diff of the actual new changes?
tests/sys/psa_crypto_persistent_storage/test_psa_crypto_store_persistent_asym_keypair.c
Outdated
Show resolved
Hide resolved
Sorry, I did a rebase, because the first version of this PR was still based on the code before the changes we made in #19992 and I wanted to have most current version. But I will consider this in the future =) |
472e07f
to
bf6a943
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'm sorry that I didn't think of this before, but keys marked as persistent should really be stored to flash unconditionally, right?
Edit: Alright, scratch that, just had another look and found the call to persist the key in psa_finish_key_creation
.
sys/psa_crypto/psa_persistent_storage/psa_crypto_persistent_storage.c
Outdated
Show resolved
Hide resolved
bf6a943
to
9b4228d
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.
Thanks again for your work! LGTM :)
@Teufelchen1 are we allowed to merge this for the next release? 👉👈
Head branch was pushed to by a user without write access
07faa14
to
9a1255b
Compare
9a1255b
to
cbadc4f
Compare
Great, congrats! 🎉 |
Hey, short question: Why does this only work on the nrf52840dk and native ? |
I think™ the implementation should work on all boards supporting MTD, but has only been tested on |
As Mikolai said, it should work with Boards that support MTD. I just haven't tested it with all of them and can't guarantee that it works. |
Contribution description
This is an implementation of persistent key storage in PSA Crypto. It uses VFS with littlefs2 and MTD.
PSA keys are encoded in CBOR, written to files and stored in flash (or emulated flash, depending on the MTD implementation).
So far this works on
native
and thenRF52840dk
and it requires that the board supports MTD. This is why it is optional and must be enabled explicitly when building PSA Crypto.Testing procedure
tests/sys/psa_crypto_persistent_storage
andtests/sys/psa_crypto_cbor_encoder
should pass successfully on the supported platforms.examples/psa_crypto
should still build and run without problems.Issues/PRs references
Probably needs to be updated once #19992 is merged, since this does not yet include the module separation.