Re: [Cfrg] On why point and APIs formats matter (Re: Submission of curve25519 to NIST from CFRG -> was RE: On "non-NIST")

Nico Williams <nico@cryptonector.com> Thu, 12 March 2015 05:37 UTC

Return-Path: <nico@cryptonector.com>
X-Original-To: cfrg@ietfa.amsl.com
Delivered-To: cfrg@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A1C331A8A67 for <cfrg@ietfa.amsl.com>; Wed, 11 Mar 2015 22:37:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.266
X-Spam-Level:
X-Spam-Status: No, score=-0.266 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, IP_NOT_FRIENDLY=0.334, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=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 bRY21AnEUzGo for <cfrg@ietfa.amsl.com>; Wed, 11 Mar 2015 22:37:32 -0700 (PDT)
Received: from homiemail-a87.g.dreamhost.com (sub4.mail.dreamhost.com [69.163.253.135]) by ietfa.amsl.com (Postfix) with ESMTP id 6BB831A0334 for <cfrg@irtf.org>; Wed, 11 Mar 2015 22:37:32 -0700 (PDT)
Received: from homiemail-a87.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a87.g.dreamhost.com (Postfix) with ESMTP id 3DF3826C07E; Wed, 11 Mar 2015 22:37:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=cryptonector.com; bh=aBo4mt7SN8pHV6 G7xIYQ3l+aHVo=; b=YsXeECbXqHQcqn7QdxV6eSwMKNhOxwpVq8VlDHfsR7dQxp 8Yh3Ogg1V5A8ctnLM/PuYvVe6LYlz2eAHGDKC1QecitfBerNnvbuyslTEw8IRKAG G5Q94Q2TVJeYZQGTxSVY9SBGW6oKcaiSi7dhLKxWkyaPrvefZ5pk+Jsxc6awo=
Received: from localhost (108-207-244-174.lightspeed.austtx.sbcglobal.net [108.207.244.174]) (Authenticated sender: nico@cryptonector.com) by homiemail-a87.g.dreamhost.com (Postfix) with ESMTPA id D872126C05E; Wed, 11 Mar 2015 22:37:30 -0700 (PDT)
Date: Thu, 12 Mar 2015 00:37:30 -0500
From: Nico Williams <nico@cryptonector.com>
To: Watson Ladd <watsonbladd@gmail.com>
Message-ID: <20150312053729.GM7286@localhost>
References: <CACsn0cnGci_fHMkJiHzXmdvnSbvm08AbV+VLdObw-+n7x7sdHw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <CACsn0cnGci_fHMkJiHzXmdvnSbvm08AbV+VLdObw-+n7x7sdHw@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Archived-At: <http://mailarchive.ietf.org/arch/msg/cfrg/x1L0zht2w9Y_a64fzdXA9zHxDvY>
Cc: "cfrg@irtf.org" <cfrg@irtf.org>
Subject: Re: [Cfrg] On why point and APIs formats matter (Re: Submission of curve25519 to NIST from CFRG -> was RE: On "non-NIST")
X-BeenThere: cfrg@irtf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Crypto Forum Research Group <cfrg.irtf.org>
List-Unsubscribe: <http://www.irtf.org/mailman/options/cfrg>, <mailto:cfrg-request@irtf.org?subject=unsubscribe>
List-Archive: <http://www.irtf.org/mail-archive/web/cfrg/>
List-Post: <mailto:cfrg@irtf.org>
List-Help: <mailto:cfrg-request@irtf.org?subject=help>
List-Subscribe: <http://www.irtf.org/mailman/listinfo/cfrg>, <mailto:cfrg-request@irtf.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Mar 2015 05:37:33 -0000

On Tue, Mar 10, 2015 at 07:20:31PM -0700, Watson Ladd wrote:
> On Tue, Mar 10, 2015 at 6:14 PM, Paul Lambert <paul@marvell.com> wrote:
> > It would be a mistake to delay an opportunity to send a recommendation from
> > this
> >
> > committee to NIST. Please note the quote:
> >
> >      "NIST encourages presentations and reports
> >
> >       on preliminary work that participants plan
> >
> >       to publish elsewhere."
> >
> > Your concerns about endianness are a trivial in comparison to the
> >
> > overall industry change to new public key algorithms.  Please have some
> > focus
> >
> > and do not add noise to the topic.
> 
> No, they aren't: they are actually much more important than the
> question of which curve to use. Periodically some TLS implementation
> will investigate a rare failure of their NIST ECC implementation when
> negotiating a handshake. And what will have happened is that they
> encoded the x coordinate as a DHE result is encoded, without leading
> null bytes. But this is incorrect: the x coordinate is zero padded in
> ECDHE results.
> 
> These bugs and many like them are the result of poor internal design
> of cryptography libraries, that treat all public key primitives as
> accepting bignums. If you make that design choice, then yes, using
> little-endian makes the Curve25519 implementation more difficult. But
> that design choice makes using the library much more difficult:
> instead of a single function call, the user has to make multiple calls
> to encode and decode data, before and after cryptography. For extra
> credit, ensure the decoding function cannot be used to properly
> validate PKCS 1.5 signatures, and the calls expose failures that
> shouldn't be revealed.

+1

In addition to API simplicity, for which Curve25519 sets a high bar!,
there are other reasons to stick with its use of little-endian encoding:

 - it (the encoding) is fast (not just simple)

 - code exists and has been deployed, why break it?

   Sure, if using Montgomery x-only, fixed-length, little-endian created
   a security vulnerability...  But it does not.

   (We can say that there's nothing to break.  But that's not true.  It
   means significant amounts of code will need to be modified,
   re-written, or be allowed to lapse into obsolescense.  No thanks.)

 - fixed-length coordinate encodings mean no need to add additional
   length encoding as compared to bignums (I'm repeating the simplicity
   argument here)

 - with modular DH we had true genericity (see the SSHv2 "group
   exchange" protocol, which allows the server to use a group that it
   computed if it wants to), but with ECC we've long ago left that
   behind

   We'll never have a node send parameters for curves of its own
   invention.  Therefore we don't need truly generic encodings for
   points on curves.

and finally:

 - insisting on a common point encoding is a huge complication (e.g., if
   we insisted on sending x and y, or x and sign of y) that precludes
   useful optimizations like Montgomery x-only.

   Again, a reprise of the simplicity argument, with more feeling, but
   also a more detailed rationale.

   These optimizations optimize more than bandwidth and/or CPU.  They
   also optimize away patent claims, which have a lot to do with getting
   solid crypto deployed widely.

   Nobody wanted to hammer Curve25519 into existing point encodings so
   it could be used in TLS, but many have been begging for TLS support
   for Curve25519.  The recognized solution is: let each curve dictate
   how points are to be encoded, and having done so, accept that they
   dictate different point encodings.  This is strong evidence in favor of
   this approach!

   (Incidentally, if someone wanted to use a different point
   representation for the same curve as Curve25519, they could, they'd
   just get a different curve registration, which is just fine.)

   WHY would we now try to force TLS WG back to a generic point
   encoding?  Or worse still, to a negotiable point encoding?

> Furthermore, the choice of how to represent public keys has security
> implications. Montgomery x-coordinate has, as everyone has noted, very
> large improvements in simplicity, and hence security. The fact that
> there is a unique encoding means that the API can be extremely simple
> and difficult to misuse.

This ^^^.

> By contrast, which curve to choose (out of a set with the same shape)
> doesn't have nearly the same impact on security or performance.  Given
> the preliminary nature of NISTs efforts, it's far more useful to talk
> about the important choices then the unimportant ones.

Yes.

> > The topic was a request to the Chairs to relay a position from this
> > task group
> >
> > to NIST before the March 15th deadline.
> 
> And that position should reflect the choices that impact security and
> interoperability, most of which haven't been officially made, rather
> than the ones which don't, which have been made. I don't see what we
> have to add on the subject that would represent a consensus view.

I agree with everything that Watson said above (including the bit that I
elided).  +1e6.

Nico
--