Re: [Dcrup] DKIM-Signing hashes with Ed25519

Viktor Dukhovni <ietf-dane@dukhovni.org> Wed, 14 November 2018 23:39 UTC

Return-Path: <ietf-dane@dukhovni.org>
X-Original-To: dcrup@ietfa.amsl.com
Delivered-To: dcrup@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DDD60130E73 for <dcrup@ietfa.amsl.com>; Wed, 14 Nov 2018 15:39:29 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id robBFDTD8UYn for <dcrup@ietfa.amsl.com>; Wed, 14 Nov 2018 15:39:27 -0800 (PST)
Received: from straasha.imrryr.org (straasha.imrryr.org [100.2.39.101]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3794D130E4B for <dcrup@ietf.org>; Wed, 14 Nov 2018 15:39:27 -0800 (PST)
Received: from [192.168.1.161] (unknown [192.168.1.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by straasha.imrryr.org (Postfix) with ESMTPSA id 69756324173 for <dcrup@ietf.org>; Wed, 14 Nov 2018 18:39:25 -0500 (EST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.1 \(3445.101.1\))
From: Viktor Dukhovni <ietf-dane@dukhovni.org>
In-Reply-To: <1b32eeb225568185b52691d684ea59e0b2f9f26d.camel@aegee.org>
Date: Wed, 14 Nov 2018 18:39:24 -0500
Content-Transfer-Encoding: quoted-printable
Reply-To: dcrup@ietf.org
Message-Id: <E4DE9D5E-E0A2-4D28-A674-06885194BDEA@dukhovni.org>
References: <1b32eeb225568185b52691d684ea59e0b2f9f26d.camel@aegee.org>
To: dcrup@ietf.org
X-Mailer: Apple Mail (2.3445.101.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/dcrup/KuQxralsKqQI0rHNiyZKtOFgdIE>
Subject: Re: [Dcrup] DKIM-Signing hashes with Ed25519
X-BeenThere: dcrup@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DKIM Crypto Update <dcrup.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dcrup>, <mailto:dcrup-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dcrup/>
List-Post: <mailto:dcrup@ietf.org>
List-Help: <mailto:dcrup-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dcrup>, <mailto:dcrup-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 14 Nov 2018 23:39:30 -0000

> On Nov 14, 2018, at 4:44 PM, Дилян Палаузов <dilyan.palauzov@aegee.org> wrote:
> 
> At https://www.ietf.org/mail-archive/web/dcrup/current/msg00501.html is
> stated, that GnuTLS does ED25519 signing of data, but not of hashed —
> ED25519 is not meant for the latter.  The answer at 
> https://www.ietf.org/mail-archive/web/dcrup/current/msg00502.html says,
> that “if the spec says there’s a pure version that doesn’t hash its
> input, the library would implement it.”

Suppose a + b = c, then we also say: a = c - b.

This just boils down hair-splitting as to what is the message, and what
is the signature function.

Traditionally, you take a message M and sign it with a signature function
that employs a signing algorithm S combined with a hash function H:

  let f = Sign(S, H, keys)
      signature = f(metadata || M)

Now with Ed25519 the signature primitive signs data directly, it is not
parametrized by a hash algorithm.  So the RFC boils down to:

	let f = Ed25519(keys)
	    signature = f(metadata || H(M))

i.e. instead of signing the "message" M, you sign the message H(M).
That's it.  All that changes is whether the hash H is part of the
signature function, or is used separately to prepare the message.

In general uses of Ed25519, whether to pre-hash the message or
not is an implementation choice.  The pure construction with
no pre-hash has better collision-resistance than you get with
pre-hashing, but it requires the whole message to be in memory
at the same time, so is only well-suited to sufficiently short
messages:

  https://tools.ietf.org/html/rfc8032#section-4

-- 
	Viktor.