[openpgp] Re: Encryption subkey selection

Falko Strenzke <falko.strenzke@mtg.de> Thu, 10 April 2025 07:27 UTC

Return-Path: <falko.strenzke@mtg.de>
X-Original-To: openpgp@mail2.ietf.org
Delivered-To: openpgp@mail2.ietf.org
Received: from localhost (localhost [127.0.0.1]) by mail2.ietf.org (Postfix) with ESMTP id 987721A06FA6; Thu, 10 Apr 2025 00:27:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at ietf.org
X-Spam-Flag: NO
X-Spam-Score: -2.099
X-Spam-Level:
X-Spam-Status: No, score=-2.099 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: mail2.ietf.org (amavisd-new); dkim=pass (2048-bit key) header.d=mtg.de
Received: from mail2.ietf.org ([166.84.6.31]) by localhost (mail2.ietf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b70NtltOtxvq; Thu, 10 Apr 2025 00:27:38 -0700 (PDT)
Received: from www.mtg.de (www.mtg.de [IPv6:2a02:b98:8:2::2]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail2.ietf.org (Postfix) with ESMTPS id EFC401A06F9C; Thu, 10 Apr 2025 00:27:36 -0700 (PDT)
Received: from minka.mtg.de (minka [IPv6:2a02:b98:8:1:0:0:0:9]) by www.mtg.de (8.18.1/8.18.1) with ESMTPS id 53A7RY1x022725 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT); Thu, 10 Apr 2025 09:27:34 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mtg.de; s=mail201801; t=1744270054; bh=Rb/oWX/6nsoiYNSIy9PC54oYJ25FbxeCrlcK4YqBKZU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=CJaNX0RaazmD2QVH3K8QTg+JrrhAzWAF5Fn/d1q81N+UyNMlWd388CPYozqI4YBKJ tTKbFym7cpTYTJ4kUJ11CClIfDKD7oMtZmu3r1NRjaxr3XCpfCQPUuaqOdzl8UyHpD k6CmxIXDWy/2amJADCjeVRRgpIor/8WZLUrFp7Xkz61Bt7Y18cXw0BIZhwGWjUa/2q bke8gYRM3IBFKkLaOBObqNqOMXehcJI+bp17X6mFWCd5Y2okveayiTZyaOaPKDxlOV l8BgaXMjgmbIQUEIkMu0Jn3K9g9rJTFWH6OM1V1If3ffSeQbebawjh4CWeUw6ZHpeO +Iqcya3MKLGCw==
Received: from [199.99.99.123] (dhcp123 [199.99.99.123]) by minka.mtg.de (8.18.1/8.18.1) with ESMTPS id 53A7RWKS007680 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT); Thu, 10 Apr 2025 09:27:32 +0200
Message-ID: <4460b180-8b55-4a5b-b631-657a1e8d8ed6@mtg.de>
Date: Thu, 10 Apr 2025 09:27:32 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Daniel Huigens <d.huigens=40protonmail.com@dmarc.ietf.org>
References: <87h631mvol.fsf@thinbox> <dI4YtuyWCyCqKizRafc2sNHBFSRSuQEt-03l8CBI-bRD4SPN7701nRDLFYtu0hwve96cG3Q4kIglx6oVTIAiJbVJseQRzLrt2AoKpSLes28=@protonmail.com> <301ff73c-fd6f-43e4-beb0-ecfdc8fc3c3e@mtg.de> <yV2spuz8ZDABNnxVp-miI969S1U_Rk22qGYrIr0LUdLl4Wx2Y0YP4oZJkBTW_Y-zQKGE-c2128Fmg9BQApbypEZxMYcPLKxnGr6-s-uxDS0=@protonmail.com>
Content-Language: en-GB
From: Falko Strenzke <falko.strenzke@mtg.de>
Organization: MTG AG
In-Reply-To: <yV2spuz8ZDABNnxVp-miI969S1U_Rk22qGYrIr0LUdLl4Wx2Y0YP4oZJkBTW_Y-zQKGE-c2128Fmg9BQApbypEZxMYcPLKxnGr6-s-uxDS0=@protonmail.com>
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha-512"; boundary="------------ms070505080009030607010609"
Message-ID-Hash: S6PWK7I3RZUZW4VROZWPDIQD3JZMHNN4
X-Message-ID-Hash: S6PWK7I3RZUZW4VROZWPDIQD3JZMHNN4
X-MailFrom: falko.strenzke@mtg.de
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-openpgp.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: Justus Winter <justus@sequoia-pgp.org>, openpgp@ietf.org
X-Mailman-Version: 3.3.9rc6
Precedence: list
Subject: [openpgp] Re: Encryption subkey selection
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/K8h8nyBzdYxJQeSTEPAnYyisvEI>
List-Archive: <https://mailarchive.ietf.org/arch/browse/openpgp>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Owner: <mailto:openpgp-owner@ietf.org>
List-Post: <mailto:openpgp@ietf.org>
List-Subscribe: <mailto:openpgp-join@ietf.org>
List-Unsubscribe: <mailto:openpgp-leave@ietf.org>

Hi Daniel,

from these two options I'd indeed prefer the second one, as there it is 
made explicit how the encryption keys in a single certificate are 
intended to be used.

In general I think it will be better to specs for the mechanism for 
encryption subkey selection per certificate and the replacement key 
mechanism separate. The reason is that if they are linked to closely, it 
will be unclear what an implementation does when it supports one but not 
the other. But as far as I can see, that is given in both of your proposals.

Best regards,
Falko

Am 09.04.25 um 11:28 schrieb Daniel Huigens:
> Hi Falko,
>
> I left the exact algorithm a bit open as IMO it's up for debate and 
> also depends on which variant we go with from the ones I proposed (if 
> any). In the first & simplest variant, I imagined it would be 
> something like:
>
>   * for each certificate I have, in the order given by the RKS or an
>     implementation-defined order (e.g. newest first):
>       o if the certificate contains an encryption subkey that I can use:
>           + encrypt to all valid encryption subkeys that I can use
>           + return
>
>
> This changes the behavior even in the single-certificate case, but 
> matches what Sequoia already does in that case. If you don't like that 
> behavior you might like the one below more.
> (It also doesn't properly handle the case where e.g. the first 
> certificate contains an ML-KEM-768 and an ML-KEM-1024 subkey, each for 
> a different device, and I only support ML-KEM-768, for example. But as 
> I wrote before I think that's a silly thing to do as you don't gain 
> security from using ML-KEM-1024 on one of the devices if the sender is 
> always going to use ML-KEM-768 to encrypt as well.)
>
> In the last & most flexible variant I imagined it would be something like:
>
>   * for each certificate I have, in the order given by the RKS or an
>     implementation-defined order (e.g. newest first):
>       o if the certificate says that it wants all encryption subkeys
>         to be used:
>           + if the certificate contains only encryption subkeys that I
>             can use:
>               # encrypt to all of them
>               # return
>           + else if this is the last certificate I have:
>               # encrypt to all encryption subkeys that I can use
>               # return
>       o else:
>           + if the certificate contains an encryption subkey that I
>             can use:
>               # encrypt to it
>               # return
>
>
> That way, in both cases, there are no new failure modes introduced 
> that there weren't before (which I agree is important).
>
> Just FWIW, I also want to point out that while it's obvious that the 
> second one covers more use cases than the first one, IMHO we also need 
> to keep in mind the effort it will take to test all code paths, make 
> sure all implementations are consistent in every case, and so on. The 
> more complex an algorithm we propose, the more difficult that will be. 
> So I hope we can find the simplest algorithm that covers all cases 
> that we think are absolutely necessary :)
>
> Best,
> Daniel
>
> On Wednesday, April 9th, 2025 at 08:33, Falko Strenzke 
> <falko.strenzke@mtg.de> wrote:
>>
>> Hi Daniel,
>>
>> I am not entirely sure what exact algorithm you are proposing for 
>> encryption key selection. Do you mean this?
>>
>>   * if certificate has replacement key subpacket pointing to a
>>     further certificate
>>       o while have certificates to select, process next certificate
>>         in sequence
>>           + if certificate contains only encryption subkeys that I
>>             can use:
>>               # encrypt to all of them
>>               # return
>>       o fail to encrypt (⁕)
>>   * else:
>>       o encrypt to whatever subset of encryption keys the user or
>>         implementation prefers
>>
>> That would mean that the including a replacement key subpacket (RKS) 
>> pointing to the previous key would imply that all the encryption 
>> subkeys of the certificate should be used in parallel, whereas where 
>> the subpacket is absent, the sending implementation is free to choose 
>> any set of subkeys. I am not sure if everyone who will include an RKS 
>> to point to a previous key want this behaviour. This would also 
>> retroactively change the behaviour for the certificate pointed to, 
>> which possibly was created without the assumption that all encryption 
>> subkeys should be used in parallel. It would introduce a new failure 
>> case also. Or should the last step in the outer if-clause (⁕) be: 
>> “choose one certificate and encrypt to as many of it’s subkeys as 
>> possible”?
>>
>> And do you mean that multiple certificates of the same recipient 
>> should be handled in this way in any case (where the ordering would 
>> have to be determined somehow), or only in the case that they are 
>> linked by the RKS?
>>
>> Best regards,
>> Falko
>>
>> Am 08.04.25 um 20:06 schrieb Daniel Huigens:
>>> Hi Justus & all,
>>>
>>> I agree that it would be good to reach a consensus on this, and that
>>> if we assume that we want to support one-subkey-per-device setups
>>> (e.g. for use with integrated HSMs, to be able to generate a key
>>> on each of your devices in hardware), which seemed to be the
>>> conclusion from the multi-device session at the summit,
>>> then we probably need some mechanism for that.
>>>
>>> _However_, I want to raise one specific potential solution that
>>> Patrick Brunschwig proposed in that session, which is a variant of
>>> "List of sets of subkeys", but rather than introducing some new
>>> encoding for this, we could simply say: each certificate is such
>>> a list of subkeys. In other words, we pick the first certificate,
>>> see if it's usable, if so use all valid encryption subkeys in that
>>> certificate. If not, try the next certificate. And so on.
>>>
>>> This means that, to migrate to a new encryption algorithm, you also
>>> need to generate a new certificate. Often we want to do that anyway:
>>> in the migration from RSA to ECC, and ECC to PQC, we've introduced
>>> both new encryption algorithms and new signing algorithms.
>>>
>>> I know this goes a bit against what I've said previously and also
>>> conflicts with the concept of "certificate equivalence" in the
>>> key replacement draft (because multiple subkeys across linked certs
>>> would then not behave the same as multiple subkeys in a single cert).
>>> _But_ if we all agree that we need some mechanism for this then
>>> I think it's best to pick the simplest possible mechanism.
>>>
>>> ---
>>>
>>> Alternatively, as an intermediary solution, we could have a single
>>> _per-certificate_ flag which says: please use all valid encryption
>>> keys in this certificate. (And potentially also: if you don't
>>> understand all encryption subkeys, please use the fallback
>>> certificate instead, if there is one. That being said, I think
>>> it would be a bit silly and a very niche edge case if you want
>>> to e.g. use a mix of ML-KEM-768 and ML-KEM-1024 subkeys in
>>> your latest cert, _especially_ you're going to ask the sender
>>> to encrypt to all of them, as then there's no security advantage
>>> to using ML-KEM-1024 in one/some of the subkeys).
>>>
>>> That way, we could keep the existing behavior for a single cert,
>>> if needed (so that you could still do a encryption algorithm
>>> migration within a single cert if you only have a single device),
>>> but could opt-in to the new behavior (from our perspective;
>>> obviously for Sequoia it'd be the other way around) if you have
>>> multiple devices.
>>>
>>> The only thing you then can't do is an encryption(-only) algorithm
>>> migration within a single certificate with per-device subkeys.
>>> But, that kinda seems like an edge case within an edge case..
>>>
>>> Best,
>>> Daniel
>>>
>>> _______________________________________________
>>> openpgp mailing list --openpgp@ietf.org
>>> To unsubscribe send an email toopenpgp-leave@ietf.org
>> -- 
>>
>> *MTG AG*
>> Dr. Falko Strenzke
>>
>> Phone: +49 6151 8000 24
>> E-Mail: falko.strenzke@mtg.de
>> Web: mtg.de <https://www.mtg.de>
>>
>> ------------------------------------------------------------------------
>>
>> MTG AG - Dolivostr. 11 - 64293 Darmstadt, Germany
>> Commercial register: HRB 8901
>> Register Court: Amtsgericht Darmstadt
>> Management Board: Jürgen Ruf (CEO), Tamer Kemeröz
>> Chairman of the Supervisory Board: Dr. Thomas Milde
>>
>> This email may contain confidential and/or privileged information. If 
>> you are not the correct recipient or have received this email in error,
>> please inform the sender immediately and delete this 
>> email.Unauthorised copying or distribution of this email is not 
>> permitted.
>>
>> Data protection information: Privacy policy 
>> <https://www.mtg.de/en/privacy-policy>
>>
>
>
> _______________________________________________
> openpgp mailing list --openpgp@ietf.org
> To unsubscribe send an email toopenpgp-leave@ietf.org
-- 

*MTG AG*
Dr. Falko Strenzke

Phone: +49 6151 8000 24
E-Mail: falko.strenzke@mtg.de
Web: mtg.de <https://www.mtg.de>

------------------------------------------------------------------------

MTG AG - Dolivostr. 11 - 64293 Darmstadt, Germany
Commercial register: HRB 8901
Register Court: Amtsgericht Darmstadt
Management Board: Jürgen Ruf (CEO), Tamer Kemeröz
Chairman of the Supervisory Board: Dr. Thomas Milde

This email may contain confidential and/or privileged information. If 
you are not the correct recipient or have received this email in error,
please inform the sender immediately and delete this email.Unauthorised 
copying or distribution of this email is not permitted.

Data protection information: Privacy policy 
<https://www.mtg.de/en/privacy-policy>