Re: [openpgp] [RFC4880bis PATCH] WIP: bind wire format representations to specific pubkey algorithms

Florian Weimer <fw@deneb.enyo.de> Sat, 05 June 2021 18:23 UTC

Return-Path: <fw@deneb.enyo.de>
X-Original-To: openpgp@ietfa.amsl.com
Delivered-To: openpgp@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 000823A2B73 for <openpgp@ietfa.amsl.com>; Sat, 5 Jun 2021 11:23:40 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1uLXhgE_X015 for <openpgp@ietfa.amsl.com>; Sat, 5 Jun 2021 11:23:36 -0700 (PDT)
Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 440353A2B70 for <openpgp@ietf.org>; Sat, 5 Jun 2021 11:23:36 -0700 (PDT)
Received: from [172.17.203.2] (port=43495 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1lpaxI-00023y-BH; Sat, 05 Jun 2021 18:23:32 +0000
Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from <fw@deneb.enyo.de>) id 1lpaxA-0008A9-S5; Sat, 05 Jun 2021 20:23:24 +0200
From: Florian Weimer <fw@deneb.enyo.de>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Cc: IETF OpenPGP WG <openpgp@ietf.org>
References: <20210602230847.3593022-1-dkg@fifthhorseman.net> <87eedg9u4d.fsf@mid.deneb.enyo.de> <871r9grzeb.fsf@fifthhorseman.net>
Date: Sat, 05 Jun 2021 20:23:24 +0200
In-Reply-To: <871r9grzeb.fsf@fifthhorseman.net> (Daniel Kahn Gillmor's message of "Sat, 05 Jun 2021 13:31:56 -0400")
Message-ID: <871r9g9nmr.fsf@mid.deneb.enyo.de>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/J8bz0zABIDYTqgFEvySfrVnJ5b4>
Subject: Re: [openpgp] [RFC4880bis PATCH] WIP: bind wire format representations to specific pubkey algorithms
X-BeenThere: openpgp@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/openpgp>, <mailto:openpgp-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/openpgp/>
List-Post: <mailto:openpgp@ietf.org>
List-Help: <mailto:openpgp-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/openpgp>, <mailto:openpgp-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Jun 2021 18:23:41 -0000

* Daniel Kahn Gillmor:

> Hi Florian--
>
> On Sat 2021-06-05 18:03:14 +0200, Florian Weimer wrote:
>> * Daniel Kahn Gillmor:
>>
>>> The OpenPGP standard is in a bit of a mess when it comes to wire
>>> formats for public key algorithms.
>>>
>>> There are not infrequent reports of interoperability problems (most
>>> recently https://dev.gnupg.org/T5464), and difficulties for
>>> implementers in understanding what is expected.
>>
>> I think this issue also affects RSA data because the way OpenPGP
>> specifies the operations, they are octet strings of a specific length,
>> not integers, and may including leading zero bytes.
>
> This is an unsettling message, but I'm not sure I understand what you
> mean.  Can you provide a specific example?

RFC 3447 section 8.2.2 says this about signature verification:

|   1. Length checking: If the length of the signature S is not k octets,
|      output "invalid signature" and stop.

<https://datatracker.ietf.org/doc/html/rfc3447#section-8.2.2>

Due to the way MPI encoding and decoding does no round-trip leading
zeros, some valid OpenPGP signatures (about one in every 256) cannot
be validated by PKCS#1 implementations that perform this length check.

I guess every implementor who tries to layer OpenPGP on top of an
existing PKCS#1 implementation will eventually learn about this, but I
suspect I'm not the only one who was surprised by this.