From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795064484; b=DsaJ5SV0J36KJKDQF8Q5bjcL/pCsLK5vzzAAA8Dc3p3pBtwzUORm5WNKnVN8m/osQplW 7HA9d7yjbzqLlc2SlpTQK4t/u3lB6jSsfJqubwKADTeePALHpXqMSEJ858IqSgmnF5zxD mUdB+S3491WmPoT8AS+M7aeFFVCE7KdaDtphQ1VD7DZYTe2BTh7iPanB3CSHcp/b30nk0 scPZ0m9HnrRhpKziGwCkomme9xJDp3k0WVyrOxsHzZ7epP8QqVSVWlfjEFJ5rQKTy5A9r TudzBExBIYepHzHE7tsKlxlLkEBLu4d+G8aE0EL1cFTVThqXdZN08/bpfJXQb9KPBTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795064484; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=/3gTc3OhQhIgQt6McVDsUOMeCjJgyS505Y5yzx9cgOs=; b=K3eUu7NCQyFZJcfXRMxs4V6fNKBXp0XxGIiKmrJhTkOkXvF90Yg7vMCZcB6H37JzIYlV pxXS4kjk0grqO75f5swwRVZUaFss+/uZAsyWNpycZ1MQ6WS1JfRvnYWy0TbyXMawrMFIG KlQEz4tvPCZdhQwGvMZP63W1goHUO4diNpV9sjQbJJIsgpkuJNBtHAT3oM1COD40QfHsA ZhuCk5bQjVXlaoHYHLkXPW/1ZNicbKs6mDqeynD1gCfLMKxbcov3NYJ3z0LJMJLKzEbba 6TA35hyZpIp8RG9m0mhHaYym2hO0ceeowYf2RsGf0lo8NV7IGq25w7z4o7T35XKS5ew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RNbMjuDh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id E08A6606A320; Thu, 19 Nov 2026 05:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RNbMjuDh Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id E97521F000C5; Thu, 19 Nov 2026 05:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795064483; bh=/3gTc3OhQhIgQt6McVDsUOMeCjJgyS505Y5yzx9cgOs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=RNbMjuDhiUDcZyHgp73D5m6ri7m8MwOWTKphR8qId5y/koRUl/2OZN2Idl4zlzkIl dOdKI+XMl7YQs9/bk56L+9i4m6IWT8HLT3iF42eJHckjuMzfvc5rRZrWsHnwuM/ZHQ YGbhJIDGZzqGlYZLisa2Ay9LO2FaNcUaL4BAX85XM1GxxqJsjGK4pFCETfjadu7E1x dAkJnY5r5ucSljqiEj5wXHjD+WfEV9UhBw+ZTLRV3/DfEvMceLdVv/oc1zlA4dj1M5 y05y/wrthET2C0OByrOMJGoZFsx2wXuVRkQvWzAqvsik8xOg/dLOF3wagjWs8GbpU2 jyibVMmksmzEQ== Date: Thu, 19 Nov 2026 07:01:20 +0200 From: Jarkko Sakkinen To: Demi Marie Obenour Cc: Rodolfo Giometti , David Howells , keyrings@vger.kernel.org, Herbert Xu , "David S. Miller" , Jens Wiklander , Sumit Garg , op-tee@lists.trustedfirmware.org, Horia =?utf-8?Q?Geant=C4=83?= , Pankaj Gupta , Sahil Malhotra , Ahmad Fatoum , Richard Weinberger , "Christophe Leroy (CS GROUP)" , Eric Biggers , Arnd Bergmann , Paul Moore , James Morris , "Serge E. Hallyn" , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 0/9] KEYS: keycrypt: keys that user space can use but never read Message-ID: References: <20261118140421.584086-1-giometti@enneenne.com> <650f89ef-9745-4f75-b254-80fa5ac4773d@gmail.com> <61ca7c37-7b42-48a3-be2e-95deb4d999a2@gmail.com> <01692969-8e92-4a08-bde9-aad86674504f@gmail.com> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01692969-8e92-4a08-bde9-aad86674504f@gmail.com> 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.trustedfirmware.org (lists.trustedfirmware.org [18.214.241.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 603C8606A320 for ; Thu, 19 Nov 2026 05:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=lists.trustedfirmware.org header.i=@lists.trustedfirmware.org header.a=rsa-sha256 header.s=2024 header.b=SaaUeWeQ; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RNbMjuDh Received: from lists.trustedfirmware.org (localhost [127.0.0.1]) by lists.trustedfirmware.org (Postfix) with ESMTP id B5EDC45543 for ; Thu, 19 Nov 2026 05:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.trustedfirmware.org; s=2024; t=1795064489; bh=LKqsQuqKBCs1TafOdgFmjnMpLEk70niW5HBHt0O+sxc=; h=Date:To:Subject:References:In-Reply-To:CC:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Reply-To:From; b=SaaUeWeQ9TR11HE2y7WUQV8exgeY6/mFowvPzlwAy7F7XkJqALXt+fRcnsFvVGHQL wOfjcixPikVJBEpJuy/Il6GG3Wbrh9T1rZ5Y9jTEiRhHIafkIzig46+8bQc7ijmcPM gKBhcPmkGxsLmwt4lkz42NXsjZKYYc9KvuubdtepOKT412QQ3P8tUsW2tueEud8kb2 bvw6LTyR951FiLc1pKcQ36R5EjuEWC5MXuUZM1t9Huf2fszZ11fXDDecua66MCH8CB K+2AzYN6KrcuRjVKdn5TQfLJtjzP+VRfWZ4s8DsTIbGto8HRFmBAAKdxDkeLg3sAsj ZJAxDV/JWZHAw== Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by lists.trustedfirmware.org (Postfix) with UTF8SMTPS id 51BD843264 for ; Thu, 19 Nov 2026 05:01:24 +0000 (UTC) Authentication-Results: lists.trustedfirmware.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RNbMjuDh; dkim-atps=neutral Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with UTF8SMTP id 9123646747; Thu, 19 Nov 2026 05:01:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id E97521F000C5; Thu, 19 Nov 2026 05:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795064483; bh=/3gTc3OhQhIgQt6McVDsUOMeCjJgyS505Y5yzx9cgOs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=RNbMjuDhiUDcZyHgp73D5m6ri7m8MwOWTKphR8qId5y/koRUl/2OZN2Idl4zlzkIl dOdKI+XMl7YQs9/bk56L+9i4m6IWT8HLT3iF42eJHckjuMzfvc5rRZrWsHnwuM/ZHQ YGbhJIDGZzqGlYZLisa2Ay9LO2FaNcUaL4BAX85XM1GxxqJsjGK4pFCETfjadu7E1x dAkJnY5r5ucSljqiEj5wXHjD+WfEV9UhBw+ZTLRV3/DfEvMceLdVv/oc1zlA4dj1M5 y05y/wrthET2C0OByrOMJGoZFsx2wXuVRkQvWzAqvsik8xOg/dLOF3wagjWs8GbpU2 jyibVMmksmzEQ== Date: Thu, 19 Nov 2026 07:01:20 +0200 To: Demi Marie Obenour Subject: Re: [RFC PATCH 0/9] KEYS: keycrypt: keys that user space can use but never read Message-ID: References: <20261118140421.584086-1-giometti@enneenne.com> <650f89ef-9745-4f75-b254-80fa5ac4773d@gmail.com> <61ca7c37-7b42-48a3-be2e-95deb4d999a2@gmail.com> <01692969-8e92-4a08-bde9-aad86674504f@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01692969-8e92-4a08-bde9-aad86674504f@gmail.com> X-Rspamd-Action: no action X-Spamd-Result: default: False [-8.10 / 15.00]; WHITELIST_SPF_DKIM(-3.00)[kernel.org:d:+,kernel.org:s:+]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_LOW(-1.00)[kernel.org:dkim]; DMARC_POLICY_ALLOW(-0.50)[kernel.org,quarantine]; R_DKIM_ALLOW(-0.20)[kernel.org:s=k20260515]; R_SPF_ALLOW(-0.20)[+ip4:172.234.252.31]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[172.234.252.31:from]; RCPT_COUNT_TWELVE(0.00)[32]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FREEMAIL_TO(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[kernel.org:+] X-Rspamd-Server: lists.trustedfirmware.org X-Rspamd-Queue-Id: 51BD843264 X-Spamd-Bar: -------- Message-ID-Hash: V44LHR6AQ37BSLSDADGUVM7CIWODIKHF X-Message-ID-Hash: V44LHR6AQ37BSLSDADGUVM7CIWODIKHF X-MailFrom: jarkko@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-op-tee.lists.trustedfirmware.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Rodolfo Giometti , David Howells , keyrings@vger.kernel.org, Herbert Xu , "David S. Miller" , Jens Wiklander , Sumit Garg , op-tee@lists.trustedfirmware.org, Horia =?utf-8?Q?Geant=C4=83?= , Pankaj Gupta , Ahmad Fatoum , Richard Weinberger , "Christophe Leroy (CS GROUP)" , Eric Biggers , Arnd Bergmann , Paul Moore , James Morris , "Serge E. Hallyn" , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-api@vger.kernel.org, linux- arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org X-Mailman-Version: 3.3.5 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: From: Jarkko Sakkinen via OP-TEE Reply-To: Jarkko Sakkinen X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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