Re: [PATCH bpf-next] bpf: crypto: Use AES-CBC and AES-ECB libraries

From: Karl Mehltretter

Date: Mon Aug 31 2026 - 17:26:22 EST


On Mon, Aug 31, 2026 at 12:21:39PM +0100, Eric Biggers wrote:
> There are library APIs for both of these now, which are much easier to
> use and more efficient. Reimplement BPF crypto on top of them, greatly
> simplifying the code. As part of this, the bpf_crypto_type abstraction
> layer is removed, as it's not useful.
>

This relates to my recent patch fixing state preservation in lskcipher's
unaligned path, which exercised ARC4 through BPF:

https://lore.kernel.org/r/20260829194314.42685-1-kmehltretter@xxxxxxxxx

While looking at your patch, I tested the actual BPF-visible algorithm
surface. The ECB and CBC templates allow considerably more than AES.

I compared:

A: cee9395acd80 (v7.3-rc1)
B: cee9395acd80 plus this patch

both used the same arm64 QEMU configuration and the same BPF/userspace
test artifacts. Each request was exactly one cipher block.

"OK" means context creation plus BPF encrypt/decrypt round-trip succeeded.

Algorithm Bytes A B
--------------------------------------------------------
ecb(aes) 16 OK OK
cbc(aes) 16 OK OK
ecb(aes-lib) 16 OK -ENOENT
cbc(aes-lib) 16 OK -ENOENT
ecb(anubis) 16 OK -ENOENT
cbc(anubis) 16 OK -ENOENT
ecb(anubis-generic) 16 OK -ENOENT
cbc(anubis-generic) 16 OK -ENOENT
ecb(aria) 16 OK -ENOENT
cbc(aria) 16 OK -ENOENT
ecb(aria-generic) 16 OK -ENOENT
cbc(aria-generic) 16 OK -ENOENT
ecb(blowfish) 8 OK -ENOENT
cbc(blowfish) 8 OK -ENOENT
ecb(blowfish-generic) 8 OK -ENOENT
cbc(blowfish-generic) 8 OK -ENOENT
ecb(camellia) 16 OK -ENOENT
cbc(camellia) 16 OK -ENOENT
ecb(camellia-generic) 16 OK -ENOENT
cbc(camellia-generic) 16 OK -ENOENT
ecb(cast5) 8 OK -ENOENT
cbc(cast5) 8 OK -ENOENT
ecb(cast5-generic) 8 OK -ENOENT
cbc(cast5-generic) 8 OK -ENOENT
ecb(cast6) 16 OK -ENOENT
cbc(cast6) 16 OK -ENOENT
ecb(cast6-generic) 16 OK -ENOENT
cbc(cast6-generic) 16 OK -ENOENT
ecb(des) 8 OK -ENOENT
cbc(des) 8 OK -ENOENT
ecb(des-generic) 8 OK -ENOENT
cbc(des-generic) 8 OK -ENOENT
ecb(des3_ede) 8 OK -ENOENT
cbc(des3_ede) 8 OK -ENOENT
ecb(des3_ede-generic) 8 OK -ENOENT
cbc(des3_ede-generic) 8 OK -ENOENT
ecb(khazad) 8 OK -ENOENT
cbc(khazad) 8 OK -ENOENT
ecb(khazad-generic) 8 OK -ENOENT
cbc(khazad-generic) 8 OK -ENOENT
ecb(seed) 16 OK -ENOENT
cbc(seed) 16 OK -ENOENT
ecb(seed-generic) 16 OK -ENOENT
cbc(seed-generic) 16 OK -ENOENT
ecb(serpent) 16 OK -ENOENT
cbc(serpent) 16 OK -ENOENT
ecb(serpent-generic) 16 OK -ENOENT
cbc(serpent-generic) 16 OK -ENOENT
ecb(sm4) 16 OK -ENOENT
cbc(sm4) 16 OK -ENOENT
ecb(sm4-generic) 16 OK -ENOENT
cbc(sm4-generic) 16 OK -ENOENT
ecb(tea) 8 OK -ENOENT
cbc(tea) 8 OK -ENOENT
ecb(tea-generic) 8 OK -ENOENT
cbc(tea-generic) 8 OK -ENOENT
ecb(xtea) 8 OK -ENOENT
cbc(xtea) 8 OK -ENOENT
ecb(xtea-generic) 8 OK -ENOENT
cbc(xtea-generic) 8 OK -ENOENT
ecb(xeta) 8 OK -ENOENT
cbc(xeta) 8 OK -ENOENT
ecb(xeta-generic) 8 OK -ENOENT
cbc(xeta-generic) 8 OK -ENOENT
ecb(twofish) 16 OK -ENOENT
cbc(twofish) 16 OK -ENOENT
ecb(twofish-generic) 16 OK -ENOENT
cbc(twofish-generic) 16 OK -ENOENT
arc4 1 OK -ENOENT
arc4-generic 1 OK -ENOENT
ecb(arc4) 1 OK -ENOENT
ecb(arc4-generic) 1 OK -ENOENT

This leaves only 2 of the 72 tested algorithm names: the other 70,
covering AES aliases, non-AES block ciphers, and ARC4, now return
-ENOENT.

This table describes the BPF-visible support removed by this patch. That
may well be worthwhile cleanup, but it is still the removal of existing,
likely only theoretical, support.

Thanks,
Karl