Re: [RFC PATCH 0/9] KEYS: keycrypt: keys that user space can use but never read

From: Rodolfo Giometti

Date: Thu Nov 19 2026 - 07:17:42 EST


On 19/11/2026 05:35, Demi Marie Obenour wrote:
> On 11/18/26 7:43 PM, Demi Marie Obenour wrote:
>> On 11/18/26 7:37 PM, Jarkko Sakkinen wrote:
>>> On Wed, Nov 18, 2026 at 06:42:15PM -0500, Demi Marie Obenour wrote:
>>>> AES-256-CBC isn't a suitable mode on its own, unless it's combined
>>>> with a MAC in encrypt-then-MAC. Even then, it has a 2^64 birthday
>>>> bound, so it should only be used 2^48 times with a single key unless
>>>> the key is ephemeral.

CBC is there for existing formats (craf writes files that openssl enc
can read) and because the CAAM path is CBC only. I take your points
on it.

>>>> AES-GCM is not a suitable algorithm either. If you allow encrypting
>>>> with a key loaded from persistent storage, there is no way for the API
>>>> to ensure it is only used with a unique nonce. Nonce reuse leaks the
>>>> authentication key and allows forgeries. Using random nonces isn't
>>>> good enough either: NIST only allows 2^32 encryptions in this case,
>>>> and the API can't enforce that limit.

You are right that a construction of our own is the wrong choice:
patch 9, the only GCM in the series, has no user yet and can go.

[snip]

>> The usual solution to something like this is a userspace service
>> like ssh-agent. Then you can do whatever key management you want.
>> That doesn't protect against root, but if someone can get root you
>> have bigger problems.

The threat here is root, on devices where root eventually falls: a
key root can copy decrypts that device's data offline and forever. A
service that holds the key in its memory gives that away. keycrypt
with the OP-TEE backend does not: the TA keeps the key and checks the
purpose sealed with it at every use, so even a compromised kernel can
only use it on that device, and only for that purpose.

> Also, if you need keys stored in hardware for some reason (compliance,
> time-limited exfiltration), you can use a userspace library or
> daemon that abstracts over whatever the hardware-specific API is.

Yes, that is the case I mean, and a daemon over a TEE would not give
the key away either. What it costs here is, for OP-TEE's PKCS#11 TA,
secure storage before the root filesystem exists; for the CAAM, the
only user-space path is AF_ALG cbc(paes), the one off-CPU exception
left in an interface the kernel documents as deprecated, privileged by
default, with a key format per driver and no purpose.

Ciao,

Rodolfo

--
GNU/Linux Solutions e-mail: giometti@xxxxxxxxxxxx
Linux Device Driver giometti@xxxxxxxx
Embedded Systems phone: +39 349 2432127
UNIX programming