sys/psa_crypto: Implement persistent key storage#20099
sys/psa_crypto: Implement persistent key storage#20099mguetschow merged 1 commit intoRIOT-OS:masterfrom
Conversation
4003957 to
29f2020
Compare
mguetschow
left a comment
There was a problem hiding this comment.
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
mguetschow
left a comment
There was a problem hiding this comment.
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
mguetschow
left a comment
There was a problem hiding this comment.
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.
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
mguetschow
left a comment
There was a problem hiding this comment.
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
nativeand thenRF52840dkand 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_storageandtests/sys/psa_crypto_cbor_encodershould pass successfully on the supported platforms.examples/psa_cryptoshould 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.