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

Steffen Nurpmeso <steffen@sdaoden.eu> Wed, 15 January 2025 23:36 UTC

Return-Path: <steffen@sdaoden.eu>
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 BFF54C17C8A5 for <openpgp@ietfa.amsl.com>; Wed, 15 Jan 2025 15:36:08 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.105
X-Spam-Level:
X-Spam-Status: No, score=-2.105 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=sdaoden.eu header.b="S9vAoHc6"; dkim=neutral reason="invalid (unsupported algorithm adaed25519-sha256)" header.d=sdaoden.eu header.b="4PpHd7YV"
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 QcNWn2BFN32d for <openpgp@ietfa.amsl.com>; Wed, 15 Jan 2025 15:36:02 -0800 (PST)
Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (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 5D09FC16942A for <openpgp@ietf.org>; Wed, 15 Jan 2025 15:36:00 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sdaoden.eu; s=citron; t=1736984157; x=1737650823; h=date:author:from:to:cc:subject: message-id:in-reply-to:references:mail-followup-to:openpgp:blahblahblah: mime-version:content-type:content-transfer-encoding:author:from:subject: date:to:cc:resent-author:resent-date:resent-from:resent-sender:resent-to: resent-cc:resent-reply-to:resent-message-id:in-reply-to:references: mime-version:content-type:content-transfer-encoding:content-disposition: content-id:content-description:message-id:mail-followup-to:openpgp: blahblahblah; bh=yynzD+zmvNM90w1C8N4ukLS9pqABFk2/IC4+tBMQhg8=; b=S9vAoHc6wxpTy3bTJ0D8P03E+vSZlSGlOF2PYrm3Eq6Y8tiVpaqFGm5xaflGiVZJQcryvrKj b6nxKen+a+m1GLRMAjSHiwTAFUGwYIPmkWtuZmQolVZ0CCasauOAQxzN2XzlJXhAs0pYaMX4Qy gDu2IjSnKeXekvLZvO3r9BDksI7EBOfzmsRjiy0M5BZMHp/16YSi2mKl+hhRtFwmvHPvLJn28Y iPvuyOr0o5WL+36wceJuiohOqyGWyg52gHMPchSQLHHLZRKRikhg9kEKiytENwNHBIRDOqpr66 pAY3yrRjUGwUITbWAhKjWZuvldlnCh1IkOD+AzCevOHYs9CA==
DKIM-Signature: v=1; a=adaed25519-sha256; c=relaxed/relaxed; d=sdaoden.eu; s=orange; t=1736984157; x=1737650823; h=date:author:from:to:cc:subject: message-id:in-reply-to:references:mail-followup-to:openpgp:blahblahblah: mime-version:content-type:content-transfer-encoding:author:from:subject: date:to:cc:resent-author:resent-date:resent-from:resent-sender:resent-to: resent-cc:resent-reply-to:resent-message-id:in-reply-to:references: mime-version:content-type:content-transfer-encoding:content-disposition: content-id:content-description:message-id:mail-followup-to:openpgp: blahblahblah; bh=yynzD+zmvNM90w1C8N4ukLS9pqABFk2/IC4+tBMQhg8=; b=4PpHd7YVbfpI/jK1wkUkbh0f1nDswB6dx1K18235s1+fFKjNccTMcEKVm60/dc+i49UNTXQN pO6EmEfyofYfCA==
Date: Thu, 16 Jan 2025 00:35:56 +0100
Author: Steffen Nurpmeso <steffen@sdaoden.eu>
From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: Daniel Huigens <d.huigens=40protonmail.com@dmarc.ietf.org>
Message-ID: <20250115233556.IzyQJUqy@steffen%sdaoden.eu>
In-Reply-To: <4e9oBXl8Mu7-Fcj3fn0UssCr_qyeZFhmgvf9CzVEw4-ueyG5h678x4P3x04DrTznZQs88Mcqp5mzPIoumsdAQb7gqJc6SdsZuCWLU__ugdI=@protonmail.com>
References: <gp_qhnxiYq_pgzpw26Gw5lC53i2aOD1tik9Lrprf0yhURin012f3YvwxS-8mGXOX7ObRAiMqjBkyyxiC8vkwuMMg0Kng4dSOI4Edwww0v4I=@proton.me> <C248DA16-5642-4141-8561-108F157A0D97@andrewg.com> <nLeggcwwubArYMbVyxeaaGb3-QcrtILJob0uhfTjhbXRnCUQWJv0sjwhDuXvc705DhqW2XNEJHqagEFow2v0i5L1cRAv2ixFvqDIDp3lFiQ=@protonmail.com> <55c42efdaea1bd661f5d3607706a6d4d388cea61.camel@redhat.com> <fU3_9MgtQjRnA48uQszLXegERJDcKOLGHUssln9CZfamMwBNpbD6Wj5zVpCl_DrfaTqkuJpDGsI4-13uRDyBDZuHNMtcsD5wP376GsxSWSU=@protonmail.com> <b329a33a05f8dca61571ea049357c421c48f6927.camel@redhat.com> <4e9oBXl8Mu7-Fcj3fn0UssCr_qyeZFhmgvf9CzVEw4-ueyG5h678x4P3x04DrTznZQs88Mcqp5mzPIoumsdAQb7gqJc6SdsZuCWLU__ugdI=@protonmail.com>
Mail-Followup-To: Daniel Huigens <d.huigens=40protonmail.com@dmarc.ietf.org>, Simo Sorce <simo@redhat.com>, Andrew Gallagher <andrewg@andrewg.com>, Akhil CM <akhilacm@proton.me>, "openpgp@ietf.org" <openpgp@ietf.org>
User-Agent: s-nail v14.9.25-636-gc7c14cee09-dirty
OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt
BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs.
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Message-ID-Hash: RD5ESGDGNUFH4TLOLJUP7SATE2IT3MEI
X-Message-ID-Hash: RD5ESGDGNUFH4TLOLJUP7SATE2IT3MEI
X-MailFrom: steffen@sdaoden.eu
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
CC: Simo Sorce <simo@redhat.com>, Andrew Gallagher <andrewg@andrewg.com>, Akhil CM <akhilacm@proton.me>, "openpgp@ietf.org" <openpgp@ietf.org>
X-Mailman-Version: 3.3.9rc6
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/4W2tlz5LK1x2O3cZOQ2StZeN5xQ>
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>

Daniel Huigens wrote in
 <4e9oBXl8Mu7-Fcj3fn0UssCr_qyeZFhmgvf9CzVEw4-ueyG5h678x4P3x04DrTznZQs88Mc\
 qp5mzPIoumsdAQb7gqJc6SdsZuCWLU__ugdI=@protonmail.com>:
 |Hi Simo,
 |
 |You're making an argument that goes roughly as follows:
 |
 |- I don't understand the purpose of HashML-DSA as described in FIPS 204
 |- Therefore I assume the purpose must be something else, and interpret
 |  the text of FIPS 204 differently to fit that assumption
 |- The purpose I assume is the one that would be relevant for OpenPGP
 |- Therefore we should use HashML-DSA for OpenPGP
 |
 |IMHO, this is faulty reasoning. If you don't understand the purpose
 |of HashML-DSA, that's fine. I don't see it as my job to justify the
 |existence of HashML-DSA for something other than being used in OpenPGP.
 |For all I care it might be completely useless and nobody implements it,
 |like what happened with the pre-hash variants of EdDSA.
 |
 |In any case I prefer to take the text in FIPS 204 at face value, and
 |the straightforward reading of the text says that we shouldn't use it.
 |
 |
 |> The explanation in 5.4, the whole point of providing a pre-hash ML-DSA
 |> version is to allow application to doh!) "pre" Hash the message.
 |
 |That's not what it says. It says: "Like ML-DSA, the signing algorithm of
 |HashML-DSA takes the content to be signed, the private key, and a
 |context as input, as well as a hash function or XOF that is to be used
 |to pre-hash the content to be signed."
 |So it's the HashML-DSA function itself that pre-hashes the content.
 |
 |> What would be the point of doing that, and then re-hashing the whole
 |> thing a second time ? (and then a third time internally).
 |
 |Indeed you wouldn't. That's why it says "If the content is *not* hashed
 |at the application level, the pre-hash version of ML-DSA signing may be
 |used." (emphasis mine)
 |
 |> If you are still unconvinced look at the text at the bottom of Page 20
 |> which says explicitly: "As with the pre-hash signature generation, 𝑀 ′
 |> may be constructed outside of the cryptographic module that performs
 |> ML-DSA.Verify_internal."
 |
 |The text after your quote continues "However, in the case of HashML-DSA,
 |the hash or XOF of the content must be computed within a FIPS 140-
 |validated cryptographic module, which may be a different cryptographic
 |module than the one that performs ML-DSA.Verify_internal."
 |
 |Like I said, you might have a "core cryptographic module" that's on an
 |HSM, and a different cryptographic module that computes the hash.
 |
 |> for the non-FIPS language versed "Outside the cryptographic module" ==
 |> "The application"
 |
 |So no, in this case they mean "in a different cryptographic module".
 |
 |> I know that OpenPGP does not do that, but NIST puts down general rules
 |> to follow that cover all cases. That is the spirit of the
 |> specification, and yes if you "hold it right" you can be safe using
 |> Pure ML-DSA, but why go against the spirit and the recommendation of
 |> the spec when it is rather easy to actually follow the spec and use the
 |> correct function which is HashML-DSA ?
 |
 |You still haven't actually quoted a recommendation of the spec.
 |The only relevant recommendation I see is: "In general, the “pure”
 |ML-DSA version is preferred."
 |
 |> They would not have made available HashML-DSA if there weren't
 |> legitimate cases for it.
 |
 |Like the text I quoted above says, "If the content is not hashed at the
 |application level, the pre-hash version of ML-DSA signing may be used."
 |So the exact opposite case of OpenPGP.
 |
 |
 |Btw, if your position is that you _disagree_ with NIST and/or FIPS 204,
 |like some parts of your email seem to suggest, that's perfectly fine,
 |but that's something entirely different than claiming that the spec
 |recommends something different than what it actually recommends.
 |
 |Best,
 |Daniel
 |
 |_______________________________________________
 |openpgp mailing list -- openpgp@ietf.org
 |To unsubscribe send an email to openpgp-leave@ietf.org
 --End of <4e9oBXl8Mu7-Fcj3fn0UssCr_qyeZFhmgvf9CzVEw4-ueyG5h678x4P3x04DrT\
 znZQs88Mcqp5mzPIoumsdAQb7gqJc6SdsZuCWLU__ugdI=@protonmail.com>

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)
|
|In Fall and Winter, feel "The Dropbear Bard"s pint(er).
|
|The banded bear
|without a care,
|Banged on himself for e'er and e'er
|
|Farewell, dear collar bear