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

Falko Strenzke <falko.strenzke@mtg.de> Mon, 26 August 2024 08:28 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 27BE9C14F696 for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 01:28:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.106
X-Spam-Level:
X-Spam-Status: No, score=-2.106 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, RCVD_IN_ZEN_BLOCKED_OPENDNS=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 TbSuFfzQ_i8R for <openpgp@ietfa.amsl.com>; Mon, 26 Aug 2024 01:28:02 -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 69CDFC14F600 for <openpgp@ietf.org>; Mon, 26 Aug 2024 01:28:00 -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 47Q8Rvs0002195 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT) for <openpgp@ietf.org>; Mon, 26 Aug 2024 10:27:57 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mtg.de; s=mail201801; t=1724660877; bh=OPTvKg4u0Dp6m9FIluPG9Qw2Yw0NuFoEbktAsBD1jxM=; h=Date:From:To:Subject; b=fLCrxxfVdrco6GK9bmYJiFpn7mbftGMZUAyNjDkbOfTpv7OT6KJ6Rfh7thKgdq2Cz PIawNcdzyt8wdFCUvSbxbvRZtCI3Mqjvw2l/GsPtV9ewuoSmtrzPcMx0jqaQ7Mn0gF Is1zZGP1O+JUOTIWl17gvuGDVFIxjgnhW2fMZ0mWkYX6FSqJlm0hzRNlE1enxjpsMi u7DPvU4JsbC0GC54YoUuJ/OoNvMvG9WG/SLSTZMXie/nliV1bcbkxNERZKgRyewOSo WAyqSEevVVGbO8en9bMuNdvRAVCAFSauG6jlbQNcpJT/CX6dLSk2YHTUy5dIDz1qs0 r/zxMLw9nYLzA==
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 47Q8Ruff019568 (version=TLSv1.3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256 verify=NOT) for <openpgp@ietf.org>; Mon, 26 Aug 2024 10:27:57 +0200
Message-ID: <fb9f748b-2024-4de1-849a-e52880c9a241@mtg.de>
Date: Mon, 26 Aug 2024 10:27:56 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
From: Falko Strenzke <falko.strenzke@mtg.de>
To: "openpgp@ietf.org" <openpgp@ietf.org>
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha-512"; boundary="------------ms000006060109040603050009"
Message-ID-Hash: 3AY2WJ54CBWKJRVETM44QXHVOXZ3SPLK
X-Message-ID-Hash: 3AY2WJ54CBWKJRVETM44QXHVOXZ3SPLK
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] 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/_Sfg2ofJvNSRy0RsUKGoTfDEGpg>
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>

As I had mentioned previously on this list, for the PQC drafts 
draft-ietf-openpgp-pqc and draft-ehlen-openpgp-nist-bp-comp we plan to 
use the pre-hash variants of ML-DSA and SLH-DSA. This is the formally 
correct approach.

However, we realized for two crypto libraries that the author’s 
implementations are using, that the pre-hash variants are not yet 
implemented [1,2]. This might be the case for more crypto libraries, as 
apparently, there is the widespread believe, that hash-and-sign is not 
needed. I attribute this at least in part to a misunderstanding about 
the variants “pure” vs. “pre-hash” in RFC 8032 (EdDSA) as well as FIPS 
204 and 205. The idea is to use the pre-hash variant whenever the 
message is first hashed and then input to the signature algorithm. As I 
had mentioned on this list as well, this is done – formally – wrong in 
RFC 9580, which specifies to use the pure variant of EdDSA to sign the 
hash of the message.

Let us briefly review the background for the existence of the two 
variants. The main point is that the pure and the pre-hash variants are 
domain-separated from each other. This ensures that when both variants 
are added to a protocol, no confusion can arise as whether a message was 
direcly signed or was first hashed and then signed. If the pure variant 
is used in both cases, this confusion can arise and thus a signature 
forgery vulnerability may be introduced into the protocol. This is why 
it is good practice to stick to the right choice of both variants.

However, in OpenPGP, even if the pure variant was used for both 
purposes, as long as this is done specifying different algorithm IDs, no 
signature forgeries are introduced. This is because OpenPGP includes the 
algorithm IDs in the signature digest as part of the meta data, which by 
itself ensures the domain separation.

This leads us to the question whether we should stick to specifying the 
pre-hash variants of the new PQC schemes or whether we should “resign” 
and use the pure variants also here. In order to answer this question, 
comments by implementers are welcome pointing out the situation they are 
facing regarding the support of the pre-hash variants of ML-DSA and 
SLH-DSA in the crypto libraries they depend on.

[1] 
https://github.com/paulmillr/noble-post-quantum/commit/2db3dde2fe411f0eb22175df79b8889e94a0dd90#diff-bc6b97217b17d126c799fe23e332f8a6caf021b3b7e55f6d1bc0f7dddaa613e9
[2] 
https://github.com/randombit/botan/pull/4270#issuecomment-2309574061, 
the link is directly to my comment requesting the addition of the 
pre-hash variant.

- Falko

-- 

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>