On 11/18/26 9:12 AM, Rodolfo Giometti wrote:
This patch is a proposal on its own: nothing before it needs it, so it can be discussed, or left out, apart from the rest.
aes256-cbc does not authenticate what it decrypts, and a file or a transfer longer than one call cannot be sealed with a single AES-GCM invocation without buffering all of it, nor decrypted without releasing plaintext before its tag is checked.
Add aes256-gcm-stream: the STREAM construction (Hoang, Reyhanitabar, Rogaway, Vizar) over AES-256-GCM. A message is split into segments of up to 64 KiB, each sealed with its own tag under a subkey derived with HKDF-SHA256 from the key and a 16-byte salt drawn at KEYCTL_CRYPT_OPEN; the nonce carries the segment's position and a last-segment flag, and the counter lives in the kernel, so segments can be neither reordered nor dropped from the end unnoticed. The segments go through a new ioctl, KEYCRYPT_IOC_SEGMENT, and KEYCRYPT_IOC_FINAL reports a stream whose last segment never came. A tee or hsm backend draws the salt and keeps the counter in its secure side; the sw and optee backends implement it.
Please use Cobblestone-128 or Cobblestone-256 instead. https://c2sp.org/chunked-encryption has the spec, and you can check against the implementation in pyca/cryptography or (for Cobblestone-128) the Go package filippo.io/cobblestone. This assumes your CPU has AES and GCM instructions; if not, you should see about using one that does or work with a cryptographer to standardize an alternative that doesn't need them.
Nonstandard constructions like this one are to be avoided.