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

Watson Ladd <watsonbladd@gmail.com> Thu, 10 April 2014 15:49 UTC

Return-Path: <watsonbladd@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 360C81A0281 for <tls@ietfa.amsl.com>; Thu, 10 Apr 2014 08:49:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.6
X-Spam-Level:
X-Spam-Status: No, score=-0.6 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, SPF_PASS=-0.001] autolearn=ham
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 SpyZpsKkqa_0 for <tls@ietfa.amsl.com>; Thu, 10 Apr 2014 08:49:37 -0700 (PDT)
Received: from mail-yh0-x22e.google.com (mail-yh0-x22e.google.com [IPv6:2607:f8b0:4002:c01::22e]) by ietfa.amsl.com (Postfix) with ESMTP id A05F81A027C for <tls@ietf.org>; Thu, 10 Apr 2014 08:49:37 -0700 (PDT)
Received: by mail-yh0-f46.google.com with SMTP id b6so4028761yha.33 for <tls@ietf.org>; Thu, 10 Apr 2014 08:49:36 -0700 (PDT)
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; bh=esTabkn39C1/8ZYOXALhUHlXYl5Lvh1igPgjlACQHdk=; b=tjisr0FLIbJuHMeooNdNDjFBFMNzaSnf5Zjb9VJ8NbXByNdmHvEPbZ/73ExyUUpp0n aUjLeBAPtNLclEwpjnFBlGMfSH43M/KE2ysJtqHHfED+VC4nnOjI9N4oYz62qyM8RCuJ mYHkoIdV1SWRFxvuS0I9v82H34Cb4KciYIPS8tbGenH8X6QwxBkaUUHtGrj6yTf0Q4j3 MS6aak1QuInibbrkG2ky5TM06sNKZ/KQJ103gGPDTlvQxjnxGCcWgRbZebPxMeizVQRu N8zMdgOtiY/ByrHQkVvHYgOZvImF0x5+8y1agdSbV3UYS1ty8R2JJQWR9Em7/700LPLr IaPQ==
MIME-Version: 1.0
X-Received: by 10.236.120.66 with SMTP id o42mr24330221yhh.66.1397144976598; Thu, 10 Apr 2014 08:49:36 -0700 (PDT)
Received: by 10.170.63.197 with HTTP; Thu, 10 Apr 2014 08:49:36 -0700 (PDT)
In-Reply-To: <1397118165.2419.23.camel@dhcp-2-127.brq.redhat.com>
References: <87ob3456s1.fsf@latte.josefsson.org> <20140402164340.GA14790@roeckx.be> <20140407115102.3011d2e5@latte.josefsson.org> <CACsn0cmFLO2n8d-FVVb4wu=G5T88E7rRd8b=eYo-1uMZnMxkOQ@mail.gmail.com> <5344BD77.2020106@fifthhorseman.net> <2A0EFB9C05D0164E98F19BB0AF3708C7120AC18CAE@USMBX1.msg.corp.akamai.com> <1397044231.4019.4.camel@dhcp-2-127.brq.redhat.com> <4abda243-3fc2-4087-92f8-3db02769384f@email.android.com> <1397048457.4019.22.camel@dhcp-2-127.brq.redhat.com> <CACsn0ckyaGO9hqn7pDVE2VR-TWs5v+Y6NsnCqCvrwFGyUGfZ3A@mail.gmail.com> <1397118165.2419.23.camel@dhcp-2-127.brq.redhat.com>
Date: Thu, 10 Apr 2014 08:49:36 -0700
Message-ID: <CACsn0cn6aPRTwG1f_o2p_KkNBtZY1t1Pt_ROo2CYBbEy9OiiDA@mail.gmail.com>
From: Watson Ladd <watsonbladd@gmail.com>
To: Nikos Mavrogiannopoulos <nmav@redhat.com>
Content-Type: text/plain; charset="UTF-8"
Archived-At: http://mailarchive.ietf.org/arch/msg/tls/kZ4OKcYzKAh82q6yKmSZJKg5BCI
Cc: "tls@ietf.org" <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, 10 Apr 2014 15:49:39 -0000

On Thu, Apr 10, 2014 at 1:22 AM, Nikos Mavrogiannopoulos
<nmav@redhat.com> wrote:
> On Wed, 2014-04-09 at 08:00 -0700, Watson Ladd wrote:
>
>> In fact, because you are the GnuTLS developer, I know exactly what
>> your bignum library, gmp does. And it isn't pretty: operations can
>> take different paths depending on argument size, which includes
>> lopping off zero limbs. Modulo is computed by division, which involves
>> an instruction that is notoriously variable-time on many
>> architectures.
>
> And how does this affect an ephemeral key exchange? I'll reply for you.
> It has no effect, because it is an ephemeral key exchange.

Not so: if I have a side channel that leaks to a local attacker,
ephemeral keys are just as vulnerable as long term keys.
Furthermore, Curve25519 can be used with long-term DH keys also.

>
> Being constant time, _matters_ when you do operations on a long-term
> key, not when you do one operation on a one-time-key. So in the cases
> where it matters nettle (the crypto library used by gnutls), is constant
> time, and outperforms all other implementations so far.

Of Curve25519? Do you have publicly verifiable benchmark data for this?
For P256 I'd be a little surprised: AGL and Shay Gureon have put a lot
of work into optimized assembler implementations.

>
>> Your bignum implementation is also slow.
>
> See the point above. I'd be interested to know how you figured that gmp
> is slow.

GMP works for \mathbb{Z} very well. But it can't ever skip a reduction
or a carry because you might ask it a question that requires it to
have an answer fully reduced in the next step.

If I know that I'm working modulo Z/pZ for some p, then I can pick
representatives in any ring with a morphism to Z/pZ. This extra
freedom can only help, never hurt.

>
> btw. I never mentioned implementing curve25519 using gmp or otherwise,
> because I am not going to implement the low level part of it. That's why
> I asked input from other who plan to implement it.
>
>> If you do decide to persist in this folly, reversing the bytes won't
>> stop you, sadly. But I wish it could.
>
> Please keep your poison for yourself.

"You" refers to everyone who wants to do this themselves. I wouldn't
implement it myself either.
The point is that all curves need to be treated by largely separate
code for the field arithmetic for the optimum in performance.

A byte swap is really not going to keep anyone from implementing
Curve25519: I see no reason to fight this holy war.

Sincerely,
Watson Ladd

>
> regards,
> Nikos
>
>



-- 
"Those who would give up Essential Liberty to purchase a little
Temporary Safety deserve neither  Liberty nor Safety."
-- Benjamin Franklin