Re: [RFC PATCH 0/9] KEYS: keycrypt: keys that user space can use but never read
From: Jarkko Sakkinen
Date: Thu Nov 19 2026 - 00:01:32 EST
On Wed, Nov 18, 2026 at 11:35:40PM -0500, 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:
> >>> On 11/18/26 9:04 AM, Rodolfo Giometti wrote:
> >>>> This RFC proposes a key type, "keycrypt", whose material user space can
> >>>> use for symmetric operations but never read: AES-256-CBC, HMAC-SHA256
> >>>> and an authenticated AES-256-GCM stream, through a file descriptor that
> >>>> KEYCTL_CRYPT_OPEN returns for one key and one operation.
> >>>
> >>> I haven't looked at the API, but from a cryptographic perspective,
> >>> this encourages very poor practices. AES-GCM even allows userspace
> >>> to extract the secret authentication key.
> >>>
> >>> 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.
> >>>
> >>> 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.
> >>>
> >>> For long-term keys, all of the following are much safer choices.
> >>> They have 192-bit nonces, which means that one can generate them
> >>> at random for each encryption without any problems.
> >>>
> >>> - XAES-256-GCM
> >>> - XChaCha20-Poly1305
> >>> - AEGIS-256
> >>>
> >>> AES-GCM-SIV is also okay, provided that you are fine with occasionally
> >>> leaking if two plaintexts are equal. This happens whenever there is
> >>> a nonce collision, so with probability 2^-32 after 2^32 encryptions.
> >>
> >> The exitential problem here is that KEYCTL_CRYPT_OPEN creates a circular
> >> relationship between the keyrings API and a specific key type.
> >>
> >> At hardware level I did not see any support for TPM, which narrows down
> >> the potential user base.
> >>
> >> The remaining potential user base is further reduced by those that use
> >> trusted keys; leaving out those who need to solve the assumed problem
> >> that only this patch set can presumebly sort out.
> >>
> >> And we don't really know at this point that cut. This is pretty much
> >> the break down of what is wrong here.
> >>
> >> If there is/was a problem to sort out, it should be so constrained that
> >> it should be as quick to describe as stepping over a nail really.
> >>
> >> These are the main topics what I would focus on.
> >
> > This whole patchset looks like a solution looking for a problem.
> >
> > 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.
>
> 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.
Pro-bab-ly but I'm not a huge fan of generalization ;-)
But when looking only at HSMs that is at least 99,999% true as they
appear as PKCS#11 providing smart cards with a possible prorietary API.
Other than generic smart card driver they ought not to require any
special kernel support.
> --
> Sincerely,
> Demi Marie Obenour (she/her/hers)
Br, Jarkko