Re: [TLS] Curve25519 in TLS and Additional Curves in TLS

Robert Ransom <rransom.8774@gmail.com> Thu, 23 January 2014 01:17 UTC

Return-Path: <rransom.8774@gmail.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 9A8DE1A01D5 for <tls@ietfa.amsl.com>; Wed, 22 Jan 2014 17:17:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.45
X-Spam-Level:
X-Spam-Status: No, score=-1.45 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, MIME_8BIT_HEADER=0.3, SPF_PASS=-0.001] 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 vHmRKP8pmbpK for <tls@ietfa.amsl.com>; Wed, 22 Jan 2014 17:17:39 -0800 (PST)
Received: from mail-qa0-x230.google.com (mail-qa0-x230.google.com [IPv6:2607:f8b0:400d:c00::230]) by ietfa.amsl.com (Postfix) with ESMTP id BFAA71A01B1 for <tls@ietf.org>; Wed, 22 Jan 2014 17:17:38 -0800 (PST)
Received: by mail-qa0-f48.google.com with SMTP id f11so1445079qae.21 for <tls@ietf.org>; Wed, 22 Jan 2014 17:17:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=c7rnSYsS4yVkvUmK6AUfzS4tFBG0/4RSDdo8GLZX+xY=; b=tRP616G2VF+8pJTtZnaoNsMfykAmOdT9aKttYGQndssohVNhhYb/ORbbeXyWCzv06c ppYyojIV8wtKNwaisba4wRhorMQpxe5hVvd32G3i0dG1jrtCD74TpIPr+5KTOuwH3BBN yQvmGXXcgq4fGRjVb0xEnUCv5QgATs8mqKP8wCbMEI20FTOgkUPsOyNyzd82dNJxdBDU 5MUX0Cwl/vWTAfPLdjfmbY4UhzVJemH2ey5jLMu2FrYbSY0SJaHm8yZCvUfMOQ2nlsG9 QSvy/yc802WiaYnwRYtA/mMWRj+DW/6LRV2cqs+Z8PzcvhR4MO1xKB7Mi3ycQRnxsaRw XzUQ==
MIME-Version: 1.0
X-Received: by 10.224.111.195 with SMTP id t3mr7597448qap.2.1390439857981; Wed, 22 Jan 2014 17:17:37 -0800 (PST)
Received: by 10.229.181.132 with HTTP; Wed, 22 Jan 2014 17:17:37 -0800 (PST)
In-Reply-To: <52E060D0.9030801@polarssl.org>
References: <87ob3456s1.fsf@latte.josefsson.org> <CABqy+spt7BYqjsqLAkZssGp3aY9M+iLqV+pmyr7ZN-TXmJJpVg@mail.gmail.com> <52E060D0.9030801@polarssl.org>
Date: Wed, 22 Jan 2014 17:17:37 -0800
Message-ID: <CABqy+spJoswrPovxf18QS1SGdk6K=mfny6joJm3X24Vh65oagQ@mail.gmail.com>
From: Robert Ransom <rransom.8774@gmail.com>
To: Manuel Pégourié-Gonnard <mpg@polarssl.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Cc: tls@ietf.org
Subject: Re: [TLS] Curve25519 in TLS and Additional Curves in TLS
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 23 Jan 2014 01:17:40 -0000

On 1/22/14, Manuel Pégourié-Gonnard <mpg@polarssl.org> wrote:
> On 22/01/2014 22:16, Robert Ransom wrote:

>> * The draft should specify that implementations MUST discard (i.e. set
>> to zero) the most significant bit of a received public key, for two
>> reasons: (a) Existing Curve25519 scalarmult implementations differ in
>> their handling of inputs with that bit set, and could be distinguished
>> by an active attacker using that difference.
>
> I wasn't aware that some implementations ignored the most significant bit.
> Out
> of curiosity, could you cite examples?

curve25519-donna and -donna-c64 ignore the MSB.

Nick Mathewson (Tor lead developer) tested whether Dr. Bernstein's
floating-point implementation for IA-32 in NaCl ignores the MSB; he
reported that it does.

The ‘ref’ implementation in NaCl does not ignore the MSB.

I have no idea what Dr. Bernstein's original floating-point Curve25519
implementation for IA-32 does with the MSB, but the web page
documenting it hints that it treats the MSB as part of the x
coordinate.

> One of the "selling points" of Curve25519 is that no public key validation
> is
> needed, so I find it quite unfortunate that after all there is something to
> do
> when receiving public keys.

Fingerprinting of implementations wasn't one of the security concerns
that Dr. Bernstein had in mind at the time, and it still isn't widely
considered to be a security risk.  It's certainly minor compared to
the numerous ways that NSA-curve ECDH implementations can leak their
keys.

But the bigger reason to mask off the high bit is extensibility.

>> (b) Future specifications
>> may wish to include the sign bit of an Edwards-form x coordinate in a
>> Curve25519 point format for use with other protocols (e.g. Schnorr
>> signature, Ace) without breaking backwards compatibility with use in
>> ECDH.
>>
> This is a serious concern indeed. By the way, there was another issue under
> discussion that is related: should the point format be just the 32 bytes, or
> should we use a leading byte to follow the existing practice from X9.62, as
> Salz
> Rich suggested? If we use a leading byte, maybe it's better to have two
> formats,
> one for "x coordinate only", one for "y + bit sign of x"?

* You appear to be confusing Montgomery form with Edwards form.  The
Curve25519 paper specifies ‘Montgomery-form x coordinate only’; the
other format you are suggesting seems to be ‘Edwards-form y coordinate
with sign bit of Edwards-form x coordinate’.  (Remember that the
Edwards-form y coordinate is analogous to the Montgomery-form x
coordinate.)

* There is no reason to ever transmit an Edwards-form y coordinate for
use in ECDH.  The formats that would be useful here are
‘Montgomery-form x coordinate only’ and ‘Montgomery-form x coordinate
with sign bit of Edwards-form x coordinate’.

* If you do not add a leading point-format byte, there is no reason to
specify the meaning of the high bit in this document.  If you do add a
leading byte, you will have to choose in this document whether the
sign bit is for the Edwards-form x coordinate or the Montgomery-form y
coordinate.

* Some future applications may wish to transmit an uncompressed
Edwards-form x coordinate or Montgomery-form y coordinate, not just
the sign bit.  If you add a leading byte, you'll have to choose which
coordinate to use now.  Alternatively, you could specify that
implementations of this document accept 64-byte points and ignore the
second half of the point structure.  (Note that this means
implementations of this protocol MUST ignore the second half, even if
they know how to use it in some other protocol, or they will be
distinguishable from other ECDH implementations.  I don't think that
restriction will ever be a problem for ECDH implementations.)

* Some future (non-ECDH) applications may wish to transmit an
Edwards-form y coordinate instead of a Montgomery-form x coordinate
(e.g. so that they can distinguish the point of order 2 from the
identity).  If you do not add a leading point-format byte now, those
applications will have to use a different NamedCurve in order to
indicate that they are incompatible with the point formats used for
ECDH.  (I'm not sure that this is a problem, or that any such
applications will ever exist.)

I'm currently leaning towards ‘just reserve the high bit and tell
implementations to accept and ignore the second half of a 64-byte
point structure’, but there may be good enough arguments for using a
magic byte to justify the minor downsides.


>> * The draft does not specify the curve equation of Curve25519 or the
>> basepoint for use in ECDH.
>>
> Of course it's no problem to add it. Do you think we should explain the
> arithmetic too (Montgomery ladder + differential addition formulas)?

Only if you will do it well.


>> * The ‘Security Considerations’ section suggests that Curve25519 can
>> be implemented securely using bignum libraries which leak information
>> about the numbers they operate on to a side-channel attacker, as long
>> as the internal projective representation of each point is randomized.
>>  Has this proposed side-channel countermeasure been evaluated?  If so,
>> which types of information leakage does the countermeasure render
>> harmless?
>>
> I'm not aware of any specific analysis of this countermeasure for this type
> of
> curves.

Then either (a) don't recommend that countermeasure as an alternative
to using constant-time field operations, or (b) explicitly warn that
there is no evidence that that countermeasure will be sufficient to
protect against side-channel attacks.


Robert Ransom