[jose] Re: [CFRG] Do we have unsafe uses of Ed448 and Ed25519? Fix Ed448?
Daniel Huigens <daniel.huigens@proton.ch> Wed, 11 September 2024 08:00 UTC
Return-Path: <daniel.huigens@proton.ch>
X-Original-To: jose@ietfa.amsl.com
Delivered-To: jose@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D7FF2C14F5EC; Wed, 11 Sep 2024 01:00:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.104
X-Spam-Level:
X-Spam-Status: No, score=-2.104 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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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=proton.ch
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 qLZ8EuJNagFo; Wed, 11 Sep 2024 00:59:56 -0700 (PDT)
Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) (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 875AFC14F5E2; Wed, 11 Sep 2024 00:59:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.ch; s=2zjdiuedhjf3tkawrnyyhxvo5u.protonmail; t=1726041592; x=1726300792; bh=qiThTVuQ8tDl/rQTHHdUrz6iCHKas9KVBwPg4VQRQU4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Nc2Z4f3Q7uYEikppYsEa0qv1lMXzxhuF+KNB3smRxMhsasQArc3t2sDCASSOd2pqU jmVisKxV0eXqM63F+9/pQuQ93GxRG7yJ36fCTqNb5g9a/wiBqn56liMMFtwfbCxZV6 WfNnIob6wKXGIuim9wPDOokHp4Em1c4b/2+JtZgCaSWZTQFkBHcZbpPjd1fQONPuhq esVyMw1ny2ofSzCkxFLgkRQG/zDKK/fy0UBYqPI7ih33UN4hai/NDU5GFBHM3Bnj7v wX+LpCtOcTKJJBltfURUFwhaz9UqXYAshjUwtLB5u1q+i+t8CBa9J/nzSgg280myG5 7TL8sfoBuamig==
Date: Wed, 11 Sep 2024 07:59:49 +0000
To: Phillip Hallam-Baker <phill@hallambaker.com>
From: Daniel Huigens <daniel.huigens@proton.ch>
Message-ID: <7UBoaC8dyojecRBPaTY-ox4-kUc97lmYVs7CCbK1-pSSOGciGEGpMDrmbtcvXaVwck_g450IA1NkMmeu4drw-TsIJbANOyNJTk85HTRSgLA=@proton.ch>
In-Reply-To: <CAMm+Lwhqn4Jb6+ngpn7XgewMPhp_m30sVmHHWpGOzgQL-Jb-Gg@mail.gmail.com>
References: <CAMm+Lwhqn4Jb6+ngpn7XgewMPhp_m30sVmHHWpGOzgQL-Jb-Gg@mail.gmail.com>
Feedback-ID: 37000915:user:proton
X-Pm-Message-ID: b056052cafa67f5ebb9b52a89f1ec15228183931
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="b1_ZQVc8w31VoSCjlD7qEsUvMYsqftVl3HYrtGlfoe0s"
Message-ID-Hash: MAAUJR6QYINQKW6E6E5O7Y62EDXER4WC
X-Message-ID-Hash: MAAUJR6QYINQKW6E6E5O7Y62EDXER4WC
X-MailFrom: daniel.huigens@proton.ch
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-jose.ietf.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
CC: IRTF CFRG <cfrg@irtf.org>, jose@ietf.org, cose WG <cose@ietf.org>, SPASM <SPASM@ietf.org>
X-Mailman-Version: 3.3.9rc4
Precedence: list
Subject: [jose] Re: [CFRG] Do we have unsafe uses of Ed448 and Ed25519? Fix Ed448?
List-Id: Javascript Object Signing and Encryption <jose.ietf.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/jose/RLqwskR5mbcWBHs64Q3D9Ukw3f0>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jose>
List-Help: <mailto:jose-request@ietf.org?subject=help>
List-Owner: <mailto:jose-owner@ietf.org>
List-Post: <mailto:jose@ietf.org>
List-Subscribe: <mailto:jose-join@ietf.org>
List-Unsubscribe: <mailto:jose-leave@ietf.org>
Hi Phillip, I know you said you'd write a separate email about the context parameter but as I wrote before I think it can be used to solve the issue you're describing here too. In particular, if you call Ed448(sk, SHA3-512(content), context = "SHA3-512 hash of <content type> for MyAwesomeApplication") then there's no risk of reusing the same signature with a different hash algorithm, or a different type of content, or an entirely different application (although as you said we shouldn't be sharing keys between applications anyway). The same is possible with ML-DSA and Ed25519ctx. So, I don't think there's a need to introduce new variants. The pre-hash variants of EdDSA are also already more poorly supported than the pure variants, and any new variants are even less likely to be well-supported (and thus be used to solve this problem). Of course, this doesn't answer the question of whether there are unsafe uses of Ed448 and Ed25519, but if there are, I think it's easier to tell applications to add a context parameter than to use an entirely new variant. Best, Daniel --- Daniel Huigens Cryptography Team Lead Proton AG On Tuesday, September 10th, 2024 at 20:02, Phillip Hallam-Baker <phill@hallambaker.com> wrote: > Apologies for crossposting but I am finding it impossible to follow the same conversation with the same set of people split across five different lists. > > So as I tried to understand the difference between ML-DSA pure and pre-hashed, I realized that we might have a problem in the use of Ed448 and Ed25519 *IN APPLICATIONS* and so I want to explain what I think is a possible hole in some of them. > > The concern is a downgrade attack where the attacker substitutes a weak digest for a strong one. Some people seem to think this is an implausible attack but it really is not because there is no way for the signer to control the set of digests accepted by the verifier. > > For example, Alice signs a PDF document and sends it to Bob who checks it using an application that Mallet has added his own digest verifier to. Yes, this assumes a degree of platform compromise but so does every privilege escalation attack and those are something we worry about A LOT. The reason we spent so much time over RSA signature modes was precisely because this is a critical security concern and the RSA padding matters. > > So the rule is that when you have a signature over a digest value, you MUST always sign the data itself or a manifest that includes the digest value and the digest algorithm. > > The problem comes in the definition of 'data' because if you are looking at the problem from the application side, well, the digest is data, isn't it? And I am pretty sure this is a problem because we seem to get into a lot of confused discussions whenever the topic is raised. > > ML-DSA offers two signature mechanisms, 'Pure and preHashed. Pure is the version to use when you are signing the data itself or a manifest such as the one specified in OpenPGP. Jose has the JWS Protected Header and so on. Yes, we do tell people not to roll their own crypto, but that doesn't mean we should make design choices that include landmines because we don't know who is going to walk on 'em. > > The problem in my view lies with the 'prehashed' version where ML-DSA specifies a drop in replacement for the RSA signature API. RSA can only sign a short message and as Rogaway pointed out, the encryption strength varies over the payload. So we have to use one of the manifest formats specified by a version of PKCS 1. > > ML-DSA does the job right. A program that was using RSA for signature can easily switch to ML-KEM, all they need to do is to use ML-KEM Prehashed which has the exact same interface as RSA Sign: Message Digest OID, Message Digest Value. > > Ed448 and Ed25519 specify 'preHash modes' but they do not support the RSA API. They insist that the implementation use a particular digest. Ed25519 isn't that bad because the hash is SHA-2-512 which is the only hash I use for content anyway. But Ed448 uses SHAKE256 which isn't a hash you would use for content except when doing Ed448. > > The 'Prehash modes of Ed448 and Ed25519 do solve the problem of avoiding the need to stream all the data being signed through the HSM. But from my perspective as the designer of cryptographic protocols, telling me which digest algorithm I am going to use for content is not the job of the signature algorithm designer. The choice of content digest is MY choice and I have to think about other signatures I might be making over the same content. > > So what I propose is we specify a proper prehash mode for Ed25519 and Ed448 and any other algorithm that doesn't provide binding of a chosen digest to the algorithm used to produce it by specifying a manifest format that can be applied generically. > > Does not have to be fancy, in fact I would just take the ML-DSA construction: > > 𝑀′ ← BytesToBits(IntegerToBytes(1, 1) ∥ IntegerToBytes(|𝑐𝑡𝑥|, 1) ∥ 𝑐𝑡𝑥 ∥ OID ∥ PH𝑀) > > And the only thing I would change there is to replace the ML-DSA version identifier with an OID off an IETF arc to denote the manifest construction. > > A big advantage of this approach is that we get the context input added into our scheme as well. > > One area where I disagree with FIPS204 is that I don't think it is a problem to share keys across pre and pure. If that is in fact a problem it is because we have done it all wrong. The real issue is sharing keys across different applications making a semantic substitution attack possible. And the problem there is that we need to come up with a theory of how to use the Context parameter consistently. > > I will post on that separately.
- [jose] Do we have unsafe uses of Ed448 and Ed2551… Phillip Hallam-Baker
- [jose] Re: [CFRG] Do we have unsafe uses of Ed448… Daniel Huigens
- [jose] Re: [CFRG] Do we have unsafe uses of Ed448… Phillip Hallam-Baker
- [jose] Re: [CFRG] Do we have unsafe uses of Ed448… Daniel Huigens
- [jose] Re: [lamps] Re: [CFRG] Do we have unsafe u… Markku-Juhani O. Saarinen
- [jose] Re: [lamps] Re: [CFRG] Do we have unsafe u… Daniel Huigens