support for zynqmp-aes-gcm driver
Jakob Trumpower <[email protected]> Mon, 12 May 2025 20:48:18 +0000
| Newsgroups | dev.linux.lists.cryptsetup |
|---|---|
| Message-ID | <PH0PR06MB707798438CE88E674C6A32BCE897A@PH0PR06MB7077.namprd06.prod.outlook.com> |
Hi, I am working on an embedded Linux application that uses an SoC with hardware acceleration for AES GCM and secure fused key storage. The goal is to modify dm-crypt/cryptsetup to point to the driver (zynqmp-aes-gcm.c) and use the internal key storage. This way we can program the volume key from the factory and Linux would be able to mount the volumes without user input while maintaining cold storage encryption. The driver and key storage work by writing a key value of "1" with length 1 and it then knows to always reference the internal keys for future operations. I think I have this part working, however when the kernel starts sending encryption/decryption requests something isn't correct for the way the hardware accelerator works with dm-crypt, it seems the hardware is a little whacky with how it handles the tag length. The driver calls for a software fallback cipher if the aead_request has a non-zero assoc length. I believe this is supposed to be zero because the GCM tag size is fixed in hardware and cannot be turned off or altered. Perusing other AES-GCM hardware drivers this seems to be an atypical way of handling request, and it's usually a configurable. I tried ignoring the assoclen in the cipher request, but this is breaking something somewhere else as the driver starts throwing tag mismatches once I start reading/writing to the device. I am sure there is a way I can eventually modify the driver/dm-crypt to get around this but I wanted to ask here first if I am doing something completely wrong and there is a simpler approach. For reference these are the commands I have been using, I renamed the crypto driver module to zynqgcm-random to ensure other aes-gcm drivers don't get used: cryptsetup luksFormat --type luks2 --cipher aes-zynqgcm-random --integrity aead --volume-key-file volume.key zynq_container.img here is associated tables that get created: tz: 0 2040240 crypt capi:zynqgcm(aes)-random :1:logon:cryptsetup:999a090c-28dd-4381-9fe3-519584010235-d0 0 254:0 0 2 integrity:16:aead sector_size:4096 tz_dif: 0 2040240 integrity 7:0 32768 16 J 7 block_size:4096 journal_sectors:16072 interleave_sectors:32768 buffer_sectors:128 journal_watermark:50 commit_time:10000 fix_padding Driver for reference (zynqmp not versal version): drivers/crypto/xilinx/zynqmp-aes-gcm.c Thanks, Jakob