ThePassionate opened a new pull request, #21957: URL: https://github.com/apache/nuttx/pull/21957
## Summary Four symmetric-crypto capabilities that the software crypto driver is missing, plus a style cleanup: * **crypto/cryptosoft: add AES-192/256-CBC support** - the CBC session selects the `CRYPTO_AES_192_CBC` / `CRYPTO_AES_256_CBC` variant by key length, so 24/32-byte keys stop being created as AES-128-CBC sessions. * **crypto: make COP_FLAG_UPDATE reach the cipher descriptor** - `cryptodev_op()` only set `CRD_F_UPDATE` on the hash descriptor, so a cipher session re-initialized its key stream/IV on every request and streaming a cipher through `/dev/crypto` was impossible. The flag now reaches the cipher descriptor, AES-CTR keeps a byte-level keystream tail across requests (8-byte chunks of a block work), and CBC/OFB/CFB carry the IV in the key schedule between update steps. Split requests must keep passing the IV, as the existing blfcbc test already does. * **crypto: support any GCM IV length and split AAD/payload** - `CRYPTO_AES_GCM_16` was never accepted by `CIOCGSESSION` (the CTR session ABI carves a nonce out of the key). GCM now takes a plain 16/24/32-byte key, derives the pre-counter block through GHASH for non-96-bit IVs, and the authenc path is reworked to the three-step `UPDATE_AAD` / `UPDATE` / final flow with the MAC context kept in the session. The old prepended-IV adjustment in `swcr_authenc()` (the region guarded in #21930) is removed entirely; if #21930 lands first the rebase here is trivial. A zero-length update is a no-op instead of faulting. * **crypto/cryptosoft: add AES-256-CMAC** - new `CRYPTO_AES_256_CMAC` id (45) with the 256-bit CMAC variant; the 128/256 selection follows the key length. * **crypto: fix nxstyle errors in chachapoly.c and xform.c** - long-standing issues in the two files this series touches (required by the whole-file style check). ## Impact * `crypto/`, `include/crypto/` only. New algorithm id 45 (`CRYPTO_ALGORITHM_MAX` 44 -> 45); no existing id or ABI changes. CTR keeps its nonce-in-key session ABI, so existing users (aes_alt, aesctr test) are unaffected. * The GCM-16 key format changes from "key + nonce" to a plain key - GCM-16 sessions could not be created before, so there is no existing user to break. ## Testing Board sim:sim/crypto (nuttx master e9eefaa0e9a), with the companion test PR in nuttx-apps: * `aescbc`: 6 vectors (4x RFC 3602 AES-128 + NIST SP 800-38A 192/256), each as one-shot and as a 16-byte-block update chain - `aescbc test vector 0..5 ok` * `aesctr`: 9 vectors, each as one-shot and as an 8-byte-chunk update chain (keystream tail across block boundaries) - all OK * `aesgcm`: round trip plus known-answer check of ciphertext and tag for a 96-bit and an 8-byte IV (GCM spec test case 4 parameters; the 8-byte IV exercises the GHASH pre-counter block). The expected values match an independent host implementation (python cryptography) and the published spec values for the 96-bit case. * `aescmac`: 8/8 - the four 128-bit and four 256-bit NIST vectors (the 128-bit 16-byte case also passes here because the authenc rework removes the one-byte truncation that #21930 fixes) Regression: des3cbc, aesxts, chacha20, chachapoly, hmac (35 vectors), hash (incl. huge-block and unaligned), crc32, pbkdf2, poly1305, castcbc, blfcbc, ecdsa (p256 keygen/sign/verify), dhm all pass unchanged. The `rsa` test does not finish on sim within 25 minutes - that is pre-existing master behavior (bn-based modular exponentiation), unchanged by this series and fixed by #21939. `tools/checkpatch.sh -c -u -m -g <base>..HEAD` passes; `tools/refresh.sh --silent sim:sim/crypto` reports no defconfig change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
