[openpgp] Re: OpenPGP grammar concerns (fwd: [Peter Gutmann] Re: [oss-security] Retrospective by 'gpg.fail' authors)

Andrew Gallagher <andrewg@andrewg.com> Mon, 26 October 2026 12:36 UTC

Received: from fum.andrewg.com (fum.andrewg.com [IPv6:2a01:4f9:c011:23ad::1]) (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 mx.ietf.org (Postfix) with ESMTPS id 9DB8946 for <openpgp@ietf.org>; Mon, 26 Oct 2026 12:36:25 +0000 (UTC)
Authentication-Results: mx.ietf.org; dkim=pass header.d=andrewg.com header.s=andrewg-com header.b=NE48ZCLa; spf=pass (mx.ietf.org: domain of andrewg@andrewg.com designates 2a01:4f9:c011:23ad::1 as permitted sender) smtp.mailfrom=andrewg@andrewg.com; dmarc=pass (policy=quarantine) header.from=andrewg.com
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=andrewg.com; s=andrewg-com; t=1793018178; bh=Ivo1/noTQHYHJgqn+F75E+/7zG6n0Q6LweFTMZeErsE=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=NE48ZCLa9v+lCmN7d0Mvj9UqFV5316zPMnroUb+dFIjyzWFxuI3AChhmJVXE1z8C4 PmoJHg4pNcFH5feXIkxU2aDa5n7OD9/6e0n2G1lizUUeYIbrfSRchKFLFOdhDIA4Ty Z7G3dMXOUBqlOgHGNEDGDzdzlf0jV4yL9wtHpktREsc8nmQ5echKd7zy1KiSaLgXtY 4FQP3BVX1mktwLEcfsKUiOSvDnZUer/G85opTmlEST+TdjMC5lGwuL3ug3BG9RPV+K d9ML8flknqeTVVMjCEMt+7d+dNXKaBO2nC+j50bcJXS+3mFiT5WloId0MH6I5Rvp7j zqayIlISpKobw==
Received: from smtpclient.apple (unknown [109.255.218.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by fum.andrewg.com (Postfix) with ESMTPSA id 29B145E1C9; Mon, 26 Oct 2026 12:36:18 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
From: Andrew Gallagher <andrewg@andrewg.com>
Mime-Version: 1.0 (1.0)
Date: Mon, 26 Oct 2026 12:36:06 +0000
Message-Id: <86B3DB48-79F3-43E7-8696-53DCBC519E56@andrewg.com>
References: <SY9P300MB881477C78D3D07FE72D736AC75EE612@SY9P300MB881477.AUSP300.PROD.OUTLOOK.COM>
In-Reply-To: <SY9P300MB881477C78D3D07FE72D736AC75EE612@SY9P300MB881477.AUSP300.PROD.OUTLOOK.COM>
To: Peter Gutmann <pgut001@cs.auckland.ac.nz>
X-Mailer: iPhone Mail (23H30)
X-Spamd-Bar: -----------------------
Message-ID-Hash: 4AJ6ETE6YWDR6LYJAJZPLKDUP2B56QZB
X-Message-ID-Hash: 4AJ6ETE6YWDR6LYJAJZPLKDUP2B56QZB
X-MailFrom: andrewg@andrewg.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-openpgp.ietf.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: openpgp@ietf.org
X-Mailman-Version: 3.3.10
Precedence: list
Subject: [openpgp] Re: OpenPGP grammar concerns (fwd: [Peter Gutmann] Re: [oss-security] Retrospective by 'gpg.fail' authors)
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/SvMnKki8_SwhulE9Og9mtMtKkX4>
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>

On 26 Oct 2026, at 01:52, Peter Gutmann <pgut001@cs.auckland.ac.nz> wrote:
> 
> Andrew Gallagher <andrewg@andrewg.com> writes:
> 
>> That's exactly what PGP does, there's no second encapsulation on this level.
>> The literal data packet is inside the decrypted cleartext.
> 
> No, it's not what PGP does.  With CMS the packaging is:
> 
>  Sign( data )
> 
> With PGP it's:
> 
>  Sign( Literal( data ) )

This is quite far removed from how the packets appear on the wire though, and if we’re viewing it on a higher level of API abstraction it’s just as valid to view it as (say) “SignLiteral( data )” and abstract away the fact that there is a literal packet in there.

> with a completely unnecessary double-encapsulation of the data.  All you need
> to do is change the Sign() to include a length and you can do away with the
> unnecessary double-encapsulation.

I’m struggling to see what the practical difference would be. There’s still a leading length parameter, followed by a data stream. That’s equivalent to an encapsulation format, just with the length prefixes moved around a little.

To take a counterfactual, the data stream could have been a length-prefixed field inside the OPS packet rather than a length-prefixed packet. But then you would have a length encoding of the OPS packet that included the length of the data stream, which would add one more nested length encoding rather than remove one.

A slightly better (but equivalent) design would be an OPS packet that contained the signed data but didn’t have an explicit length for it, letting it extend to the end of the OPS packet itself. But in this scenario you would also need to know where the signed data started, particularly in the multi-signature case, so you would still need some way of determining the length of the metadata part of the OPS packet - and the easiest way to do this is a length parameter. So we still have the same number of length parameters as the spec, just in different places and covering different things.

You could conceivably reduce the number of length parameters by relying on the OPS packet having a known internal structure and omitting its packet framing. But this sacrifices forward compatibility - you can’t then do nice things like signing over the same data with both a v4 and v6 key if legacy code doesn’t know the structure (and therefore the length) of a v6 OPS packet.

So yes, some of the length prefixes in PGP may seem redundant if you assume there is no need for forward compatibility. But the vast majority of length prefixes in PGP are there because we cannot assume that objects have fixed sizes, and parsers need to be able to gracefully ignore stuff from the future.

> CMS supports streaming data, and has (via ASN.1 BER) since before PGP existed.

I stand corrected. My knowledge of BER is limited.

A