CV-Bowen opened a new pull request, #22011:
URL: https://github.com/apache/nuttx/pull/22011

   ## Summary
   
   Add a frontend for the VirtIO crypto device (device id 20) and register
   it as a cryptodev driver, so `/dev/crypto` and in-kernel crypto users can
   offload to a VirtIO crypto device (QEMU, or a remote core's backend):
   
   - `drivers/virtio: add the virtio-crypto driver`: sessions on the control
     queue; cipher, hash, MAC and AEAD requests on the data queue.
     `include/crypto/virtio_crypto.h` maps cryptodev algorithm ids to VirtIO
     ones, `include/nuttx/virtio/virtio-crypto.h` holds the protocol
     definitions.
   - `include/crypto/virtio_crypto.h: map VirtIO algorithms back to
     cryptodev`, for code that receives VirtIO requests.
   - `drivers/virtio/virtio-crypto: support streaming operations`
     (`CRD_F_UPDATE`): the session is kept across calls and only the first
     chunk carries the IV. The device must keep the cipher state between
     requests; QEMU's builtin backend does not (see Testing).
   - `include/nuttx/virtio/virtio-crypto.h: add the key operation request`.
   - `include/crypto/virtio_crypto.h: remove virtio_crypto_get_iv_len()`:
     cryptodev passes the IV length with each request.
   
   The tests in nuttx-apps need the output length, the cipher direction and
   the IV length set to drive a hardware cryptodev driver; that is
   apache/nuttx-apps#{appspr}.
   
   ## Impact
   
   - New Kconfig `DRIVERS_VIRTIO_CRYPTO` (depends on `CRYPTO_CRYPTODEV`),
     default n.
   - New headers `include/crypto/virtio_crypto.h` and
     `include/nuttx/virtio/virtio-crypto.h`.
   - No change unless enabled.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   qemu-armv8a:netnsh with a VirtIO crypto device on QEMU's builtin backend,
   with `CONFIG_ALLOW_BSD_COMPONENTS`, `CONFIG_CRYPTO`,
   `CONFIG_CRYPTO_CRYPTODEV`, `CONFIG_DRIVERS_VIRTIO_CRYPTO`,
   `CONFIG_TESTING_CRYPTO`, `CONFIG_TESTING_CRYPTO_AES_CBC`. The software
   cryptodev driver (`CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO`) is not enabled, so
   the only provider is virtio-crypto. Apps with apache/nuttx-apps#{appspr}.
   The prebuilt QEMU 10.2 here has no crypto library, so QEMU 6.2 (Ubuntu
   22.04) is used:
   
   ```
   qemu-system-aarch64 -cpu cortex-a53 -nographic \
     -machine virt,virtualization=on,gic-version=3 -serial mon:stdio \
     -global virtio-mmio.force-legacy=false \
     -object cryptodev-backend-builtin,id=cryptodev0 \
     -device virtio-crypto-device,cryptodev=cryptodev0,bus=virtio-mmio-bus.0 \
     -kernel nuttx
   nsh> aescbc
   ```
   
   | | result |
   |---|---|
   | `aescbc`, one-shot encrypt and decrypt, all 6 vectors (128, 192 and 
256-bit keys) | `aescbc test vector 0..5 ok` |
   | same build without the `-device`/`-object` | `CIOCGSESSION` fails: no 
cryptodev provider |
   | `aescbc` stream part (one 16-byte chunk per call with `COP_FLAG_UPDATE`) | 
vector 0 (one block) ok; from vector 1 the second block differs: QEMU's builtin 
backend does not keep the CBC state between requests (see the streaming commit) 
|
   
   The one-shot row was run with the stream calls of `aescbc` skipped
   locally. AES-CTR and AES-XTS are not run: their test vectors use the
   software driver's IV layout.
   
   <details><summary>log</summary>
   
   ```
   aescbc test vector 0 ok
   aescbc test vector 1 ok
   aescbc test vector 2 ok
   aescbc test vector 3 ok
   aescbc test vector 4 ok
   aescbc test vector 5 ok
   aescbc test ok
   ```
   </details>
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 15/15). No regression in virtio: qemu-armv8a:netnsh boot and pass the 
fixed virtio cases (rng, blk on mmio and pci, net, 9p; 24/24). qemu-armv8a was 
built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current master 
needs for nxinit to start nsh there; unrelated to this 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]

Reply via email to