Repository navigation
testing/crypto: add key management test - #4092
Conversation
fde9d52 to
7b04a15
Compare
7b04a15 to
94047c9
Compare
94047c9 to
c182975
Compare
Some hints from Claude please verify if that makes sense:
|
|
And this one does that make sense??
|
c182975 to
ec76c0d
Compare
|
Thanks for the thorough review. Addressed in ec76c0d:
Also fixed: the file is renamed to keymanagement.c (matching the vela naming) and uses Apache-2.0. |
|
I would still fix the key store state mismatch between success and error run:
|
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
CI run: https://github.com/apache/nuttx-apps/actions/runs/44757086399 |
ec76c0d to
7f6b2f4
Compare
|
@ThePassionate please fix the conflict |
6ef6424 to
bfd12b5
Compare
0165bc5 to
2ad499c
Compare
|
The conflict is fixed: the earlier rebase had left the marker lines of the CMakeLists.txt resolution in the file. They are removed and the branch is rebased onto current master. The three comment corrections from the review are in this push as well - they were described in the earlier reply but had not actually made it into the commit, sorry for the confusion:
The key store state on failure is addressed too: every case now deletes the ids it holds when a step fails, best effort, before returning. Ids that were never allocated stay 0, which the store rejects, so the cleanup is a no-op for them; the delete removes the cache entry and the flash entry, so a saved key is gone as well. The comments on keyid.c and TESTING_CRYPTO_KEYID predate the rename to keymanagement.c / TESTING_CRYPTO_KEY_MANAGEMENT; the file carries the Apache-2.0 header, and the Kconfig stays without the hard depends for the reason given earlier (the key-id interface is backend-agnostic; the software store is just its first backend). apache/nuttx#22061 is merged since 11-22; the six cases were rerun on sim:sim/crypto against current master and pass. |
|
|
Fixed: cleanup when a case fails Every case now jumps to a single
Also improved
Still open (all minor)
The change you requested is done, and done correctly. I'd approve after the |
Exercise the cryptodev key-id mechanism: with SOP_F_KEYID the key field of a session or kprocess request references an imported key in the swkey store instead of the key material. Every case runs a full key lifecycle (allocate, import, operate by key id, delete) - the delete also on the failure paths, so a failed run leaves nothing behind in the store: the lifecycle round trip itself, AES-CBC, HMAC, AES-CMAC (cipher and mac keys both by id), ECDSA (generate then sign/verify by id) and RSA-1024 (n/e/d as three key ids: encrypt/decrypt round trip and a raw private-key operation with type-2 padding, checked with the public key). Signed-off-by: makejian <makejian@xiaomi.com>
2ad499c to
fefdc9c
Compare
|
The wording is fixed: the header comment and the commit message now say On the The remaining items are cosmetic - the failed-run sessions are freed when the descriptors close, and the casts and the printf wording don't change behavior - so I left them as they are. |
|
Summary
Add a
keymanagementtest for the key-id mechanism of apache/nuttx#22061 (SOP_F_KEYID): every case runs a full key lifecycle (allocate, import, operate by key id, delete) through the swkey store on/dev/nvs, and deletes the ids it holds when a step fails, so a failed run leaves nothing behind in the store:keymanagement lifecycle- allocate/import/delete round tripaescbc keyid- RFC 3602 vector, session key by idhmac keyid- HMAC-SHA256, mac key by idaescmac keyid- NIST vector, cipher and mac keys both by idecdsa keyid- CRK_GENERATE_SECP256R1_KEY, then sign/verify referencing the generated key idrsa keyid- RSA-1024 with n/e/d as three separate key ids: encrypt/decrypt round trip and a raw private-key operation with type-2 padding, checked with the public keydepends-on: apache/nuttx#22061.
Impact
TESTING_CRYPTO_KEY_MANAGEMENToption (default n).Testing
Tested on sim:sim/crypto against current master (apache/nuttx#22061 merged) with
CONFIG_CRYPTO_CRYPTODEV_SOFTWARE_KEYMGMT=yand an NVS-backed/dev/nvs:tools/checkpatch.shpasses.