Skip to content

testing/crypto: add session clone test - #4069

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
ThePassionate:crypto-clone-test
Nov 18, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
ThePassionate:crypto-clone-test

Conversation

@ThePassionate

Copy link
Copy Markdown
Contributor

Summary

Add a clone test for the cryptodev session clone (CIOCCLONE, nuttx#21932):

  • sha256, HMAC-SHA256 and AES-CMAC sessions are updated with the first half of a message, cloned with CIOCCLONE, and the source and the clone then finish independently - both results must equal the one-shot digest of the full message.
  • A close-source case verifies that the cloned session stays usable after the source descriptor is closed.
  • An AES-CBC case clones a cipher session, closes the source and encrypts independently, covering the key-schedule ownership of the clone.

Follows the plain main() style of the existing tests (hmac.c, aescbc.c).

Impact

  • Testing only. New TESTING_CRYPTO_CLONE option (default n).

Testing

Depends on apache/nuttx#21932 for the CIOCCLONE ioctl.

Board sim:crypto with the kernel PR applied:

nsh> clone
clone sha256 success
clone hmac-sha256 success
clone aes-cmac success
clone close-source success
clone aes-cbc success

tools/checkpatch.sh -c -u -m -g <base>..HEAD (via the paired nuttx tree) passes.

Test the CIOCCLONE ioctl added by the session clone change: feed half
of the input to a digest, clone the descriptor, finish the source and
the clone separately and check each against a one-shot result. Covers
SHA-256, HMAC-SHA256, AES-CMAC, closing the source descriptor after
the clone, and an AES-CBC session cloned and used after its source
descriptor is closed, which checks that the clone owns an independent
copy of the key schedule.

Cipher stream cloning (update halfway, clone, continue both streams)
is left out: cryptodev does not propagate COP_FLAG_UPDATE to the
cipher descriptor yet, so a cipher stream cannot be continued across
CIOCCRYPT calls.

Signed-off-by: makejian <makejian@xiaomi.com>
@xiaoxiang781216
xiaoxiang781216 merged commit 0961d19 into apache:master Nov 18, 2026
41 checks passed
@ThePassionate

Copy link
Copy Markdown
Contributor Author

@acassis @GUIDINGLI gentle ping — this one is ready from our side (CI green, all checks pass). Could you take a look when you have a chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants