[openpgp] Re: pure vs. pre-hash in FIPS 204 and 205

Justus Winter <justus@sequoia-pgp.org> Mon, 26 August 2024 12:17 UTC

Return-Path: <justus@sequoia-pgp.org>
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 55B5DC169418 for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 05:17:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.107
X-Spam-Level:
X-Spam-Status: No, score=-2.107 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, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (4096-bit key) header.d=sequoia-pgp.org
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O1GGLxDbKXTR for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 05:17:51 -0700 (PDT)
Received: from harrington.uberspace.de (harrington.uberspace.de [185.26.156.85]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E2265C13AE25 for <openpgp@ietf.org>; Mon, 26 Aug 2024 05:17:50 -0700 (PDT)
Received: (qmail 30746 invoked by uid 500); 26 Aug 2024 12:17:47 -0000
Authentication-Results: harrington.uberspace.de; auth=pass (plain)
Received: from unknown (HELO unkown) (::1) by harrington.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 26 Aug 2024 14:17:47 +0200
From: Justus Winter <justus@sequoia-pgp.org>
To: Falko Strenzke <falko.strenzke@mtg.de>, "openpgp@ietf.org" <openpgp@ietf.org>
In-Reply-To: <5e4fd25f-3f2d-4263-a9f6-4370f308c90e@mtg.de>
References: <fb9f748b-2024-4de1-849a-e52880c9a241@mtg.de> <87plpvwrcj.fsf@europ.lan> <5e4fd25f-3f2d-4263-a9f6-4370f308c90e@mtg.de>
Date: Mon, 26 Aug 2024 14:17:46 +0200
Message-ID: <87mskzwk9h.fsf@europ.lan>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-="; micalg="pgp-sha512"; protocol="application/pgp-signature"
X-Rspamd-Bar: ----
X-Rspamd-Report: BAYES_HAM(-2.732035) SIGNED_PGP(-2) MIME_GOOD(-0.2)
X-Rspamd-Score: -4.932035
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sequoia-pgp.org; s=uberspace; h=from:to:subject:date; bh=A1VkRhD/mra3vkvFxKBLHcFMP3/F7pQXdCwwD3EMES0=; b=twqbHkXb38pASlSnT16bV1h+znNsRIp+kwq6uKP1bJzkcRaDBg7ZhaSi7M+8+tNvWNDASUJBbb MKWjp9B9vw1Sc37d73IdSlDQk4M+mMSs1qRhCDOP9FYFUuPf3tvr4/VcP4XvJseZp4pzgaUwGvCY /Dp2YXXFYlH0nZ5cEukAtTDRq1o6X9q+SlcWFuBY/3sQdh7b0C+rpEITr+J1WSABjKwh9KwXzSOm ofFEmkY/7TKNEDsaVfKZaItzk7Meq49lknWUYpBLl2GMVm94KarwAJLaNxkSVhviQKXH3eDY2Ddl tpbgwDInk+AuppkAV6k1hH7zWIdCeOipNVZe4+MWIKtWS6FwnI1FeHBaIL5Rguo/MTxbYz2Toymv 2gV+n/RdQA8TDXiN6OtmOr2vdn/taeIvMxX/Qb+FYr+6wHBTzqCRSVs0aX3QlTAhcZrxvT9hDpPk /qb1EIxp2y5IQ8AVDMVEDhYrXtlq07OOhco9CAB8lQ/XV0/Z9sLgPygcZlwYwwxxUuorPwf0t3xV IibMhTu8BZ6LYp7JAU6lByQlQPsgOmaswWOPDf7P6fKJ45YydGKEvKqqi+V1wecAhLVRuscIloJS F81PkN2lRQgxWGk/Ap9/0FhXtBSKVBdDp7XyTTRJiNWmSrrNOFo7rsz5o4BagNivV5MH99/q+C2d w=
Message-ID-Hash: XD4W7AGWJPYYZKMGLGBV6VKKSZDU5BNG
X-Message-ID-Hash: XD4W7AGWJPYYZKMGLGBV6VKKSZDU5BNG
X-MailFrom: justus@sequoia-pgp.org
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
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [openpgp] Re: pure vs. pre-hash in FIPS 204 and 205
List-Id: "Ongoing discussion of OpenPGP issues." <openpgp.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/openpgp/fgIbxw5qTpozxnxZn_DG45qiUKw>
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 Falko :)

thanks for the explanation.  I think I understand now.

Falko Strenzke <falko.strenzke@mtg.de> writes:

>> On the other hand, if OpenPGP were to use the HashEdDSA variant, we'd
>> compute:
>>
>>    sig = PureEdDSA(PH(Hash(OpenPGP_Hash_Stream)))
>>                       ^ This happens in OpenPGP
>>                    ^ This is the prehash in HashEdDSA
>>
>> Which seems not ideal.
>
> This is the point of the misunderstanding. There is no double hashing.
> PH(OpenPGP_Hash_Stream) is the only hash that happens.

I see.  I guess what contributed to my misunderstanding this is that
PH(OpenPGP_Hash_Stream) seems impossible to implement: it combines
hashing and signing into one operation, breaking both OpenPGP's model
and every existing implementation, therefore, I guess I concluded that
PH(Hash(OpenPGP_Hash_Stream)) is the only conceivable way to implement
this.

For the record, Nettle only implements PureEdDSA.  I can see that the
implementation seems to be extensible to HashEdDSA, but this has to be
done in the library (i.e. cannot be done by a consumer), and it would
require a different kind of interface for signature creation and
verification where you can stream the data into.

I see that Botan has that kind of streaming interface, but the Rust
bindings do not export a streaming interface.  I haven't looked at other
libraries.

So circling back to your original question, I believe that for
implementers requiring a signing algorithm of the pre-hashed variant is
a major burden.  Even if all the cryptographic libraries would support
the pre-hash variant with a suitable streaming interface (which they
don't for EdDSA), we'd have to stuff the signing/verification algorithm
into places where we up to now only have hash algorithms.  It is not
that it couldn't be done, but since it breaks the mold, it is a hassle.


Best,
Justus