ThePassionate opened a new pull request, #22170:
URL: https://github.com/apache/nuttx/pull/22170

   ## Summary
   
   Extends the virtio crypto transport to the full cryptodev feature set and 
adds the device-side counterpart, ported from the Xiaomi Vela production stack:
   
   * **protocol header** (`include/crypto/virtio_crypto.h`): the AKCIPHER 
(asymmetric) service - the ECDH algorithm id, the GENKEY/DERIVE request 
opcodes, the curve id table and the DER encode/decode helpers that carry RSA 
and ECDSA keys over the wire - plus the algorithm ids the cryptodev core gained 
since the header was written (ChaCha20, AES-256-CMAC, AES-192/256-GMAC, 
HMAC-SHA-224, PBKDF2). The per-request PBKDF2 iteration count rides in the 
spare room of the data request union, so the wire layout of session-less 
requests is unchanged.
   * **virtio-crypto frontend** (`drivers/virtio/virtio-crypto.c`): requests 
are now built through virtio_map_buf()/virtio_unmap_buf(), which keeps the 
driver working when the device's buffers are not DMA addressable; CRD_F_UPDATE 
/ CRD_F_UPDATE_AAD streaming is forwarded so cipher, hash/MAC and AEAD sessions 
can spread one operation over several requests; the cryptodev key operations 
(RSA encrypt/decrypt/sign/verify, ECDSA sign/verify/genkey, ECDH 
generate/derive) run through short-lived AKCIPHER sessions on the control queue.
   * **vhost-crypto backend** (new, `drivers/vhost/vhost-crypto.c`, 
`CONFIG_DRIVERS_VHOST_CRYPTO`): the device-side counterpart of the protocol. 
Control-queue session requests become cryptodev sessions through 
crypto_newsession(), data-queue requests are replayed as 
crypto_invoke()/crypto_kinvoke() against the locally registered backends with 
the same streaming model as the frontend, plus the asymmetric counterpart.
   
   Fixes over the in-tree symmetric frontend found while porting: 
create-session now sends the real authenticated key length instead of a 
per-algorithm constant, AEAD sessions use the AEAD control opcode instead of 
the MAC one, GMAC sessions are negotiated through the AEAD service (matching 
what the backends implement), the RSA private-key DER export passes dp/dq with 
the right bit counts, and the remove path unregisters the last algorithm slot 
(the registration loop marks CRYPTO_ALGORITHM_MAX as supported).
   
   Consumes the merged kernel crypto interfaces: CRYPTO_OP_*/CRYPTO_KEY_TYPE_*, 
the RSA/ECDSA/ECDH CRK_* commands, CRD_F_UPDATE/UPDATE_AAD, crp_iter, 
crypto_kregister()/crypto_kinvoke() and virtio_map_buf()/virtio_unmap_buf().
   
   ## Impact
   
   No board configuration enables the new backend yet; the transport wiring 
(rptun/ivshmem vdev) is deliberately left to follow-ups, so the drivers are 
inert unless enabled. New options: `CONFIG_DRIVERS_VHOST_CRYPTO` and 
`CONFIG_DRIVERS_VHOST_CRYPTO_RSA_KEYBUF_SIZE` (default 1536).
   
   ## Testing
   
   Built with sim:sim/crypto plus `CONFIG_DRIVERS_VIRTIO_CRYPTO=y` and 
`CONFIG_DRIVERS_VHOST_CRYPTO=y` (openamp v2025.10.0 + libmetal materialized in 
tree): 0 warnings, 0 errors; `tools/checkpatch.sh` clean; `tools/refresh.sh 
--silent sim:crypto` shows no defconfig drift. The existing crypto tests are 
unaffected (no defconfig enables the drivers).
   


-- 
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]

Reply via email to