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

Falko Strenzke <falko.strenzke@mtg.de> Tue, 27 August 2024 06:33 UTC

Return-Path: <falko.strenzke@mtg.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 D43C1C1516EA for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 23:33:40 -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, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, 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 (2048-bit key) header.d=mtg.de
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 NYLzgaA99k1U for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 23:33:35 -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 ietfa.amsl.com (Postfix) with ESMTPS id 79DCDC15153F for <openpgp@ietf.org>; Mon, 26 Aug 2024 23:33:33 -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 47R6XTQw004121 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT); Tue, 27 Aug 2024 08:33:29 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mtg.de; s=mail201801; t=1724740409; bh=q605wBy1zgfUxCvhQyCsjP2R7QVVtjHhbnGcZwddQwE=; h=Date:Subject:From:To:References:In-Reply-To; b=S8j87fBLwe2/KTmFPj+r1SYC0z067XFmWLs633hO1t19OlwRw/iuChpwt3W8TvBQJ uOGJzOZP2zo8pZHcgBuk6CEPvv32Z2HnQlRPrsqRk/6s6cuRXkGh7hLd3j5kvqcrdY a+sa/leLfdtw63bVx328zRYzk0zLZ/IXGipWPkSsQMK9HuaeLUUAPWzZ7HJwKfXrzW rPyr5KmJk89Qz8ff75gVipQeZSTg4BQAOEywoFt6EKffeMn+p1KCHW2oYSMDPaNWWd B4FQysKXqHpRvCVfUEXLMrtek6aoaOumgdUuWB5TdeE5IASLFGdtTxoNjkiyqem0zP 3ggT6iqzKrFWQ==
Received: from [10.8.0.100] (vpn-10-8-0-100 [10.8.0.100]) by minka.mtg.de (8.18.1/8.18.1) with ESMTPS id 47R6XSeq001748 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT); Tue, 27 Aug 2024 08:33:28 +0200
Message-ID: <d4d8227b-a168-40c9-b134-80a8a699862f@mtg.de>
Date: Tue, 27 Aug 2024 08:33:28 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: Falko Strenzke <falko.strenzke@mtg.de>
To: Justus Winter <justus@sequoia-pgp.org>, "openpgp@ietf.org" <openpgp@ietf.org>
References: <fb9f748b-2024-4de1-849a-e52880c9a241@mtg.de> <87plpvwrcj.fsf@europ.lan> <5e4fd25f-3f2d-4263-a9f6-4370f308c90e@mtg.de> <87mskzwk9h.fsf@europ.lan> <06f31826-0ba2-4087-9ea2-140d24245ace@mtg.de>
Content-Language: en-GB
In-Reply-To: <06f31826-0ba2-4087-9ea2-140d24245ace@mtg.de>
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha-512"; boundary="------------ms060300020500070001050904"
Message-ID-Hash: 674EAC3UGU6VBLDLLVUJXHQ6MDFAXRFI
X-Message-ID-Hash: 674EAC3UGU6VBLDLLVUJXHQ6MDFAXRFI
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
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/VfI09HvA7saIVwdtPq_IWXmqcYI>
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>

Forgot to post that one to the list, too...

Am 26.08.24 um 15:43 schrieb Falko Strenzke:
>
> Hi Justus,
>
> Am 26.08.24 um 14:17 schrieb Justus Winter:
>> 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.
>
> Switching to HashEdDSA in the PQC hybrids is nothing we currently 
> planned anyway. It would be more consistent to use the pre-hash 
> variant (if we choose it) for both the PQC scheme and the EdDSA scheme 
> together, but this would, as you report for your implementation, most 
> likely bring even further pain points for implementers.
>
> I looked at the implementation of HashEdDSA in Botan. Indeed, it seems 
> that even the C++ interface doesn't allow to compute the hash 
> separately and then sign it. That's too bad.
>> 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.
>
> With a proper interface of the crypto library for the pre-hash variant 
> you shouldn't need a streaming interface. That's the whole point of 
> the pre-hash variant, all the processing can remain as it is: you 
> compute the hash of the message, and when it comes to calling the 
> signing function, you provide this hash as the input, just as for RSA 
> or ECDSA. However, as we've seen it's not guaranteed that a) the 
> library implements the pre-hash variant at all, and b) if it it 
> implements it, it does so in sensible way.
>
> Best regards,
> Falko
>
>> Best,
>> Justus
> -- 
>
> *MTG AG*
> Dr. Falko Strenzke
>
> Phone: +49 6151 8000 24
> E-Mail: falko.strenzke@mtg.de
> Web: mtg.de <https://www.mtg.de>
>
> <https://www.linkedin.com/search/results/all/?fetchDeterministicClustersOnly=true&heroEntityKey=urn%3Ali%3Aorganization%3A13983133&keywords=mtg%20ag&origin=RICH_QUERY_SUGGESTION&position=0&searchId=d5bc71c3-97f7-4cae-83e7-e9e16d497dc2&sid=3S5&spellCorrectionEnabled=false> 
>
> Follow us
> ------------------------------------------------------------------------
> <https://360-german-security-alliance.de/> 
> <https://www.itsa365.de/de-de/companies/m/mtg-ag>
>
> 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>
>
-- 

*MTG AG*
Dr. Falko Strenzke

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

<https://www.linkedin.com/search/results/all/?fetchDeterministicClustersOnly=true&heroEntityKey=urn%3Ali%3Aorganization%3A13983133&keywords=mtg%20ag&origin=RICH_QUERY_SUGGESTION&position=0&searchId=d5bc71c3-97f7-4cae-83e7-e9e16d497dc2&sid=3S5&spellCorrectionEnabled=false> 

Follow us
------------------------------------------------------------------------
<https://360-german-security-alliance.de/> 
<https://www.itsa365.de/de-de/companies/m/mtg-ag>

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>