Re: [TLS] Twist security for brainpoolp256r1

Ilari Liusvaara <ilari.liusvaara@elisanet.fi> Sat, 15 November 2014 06:06 UTC

Return-Path: <ilari.liusvaara@elisanet.fi>
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 3325B1A03E3 for <tls@ietfa.amsl.com>; Fri, 14 Nov 2014 22:06:06 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, 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 ehHgvbqSwOlH for <tls@ietfa.amsl.com>; Fri, 14 Nov 2014 22:06:02 -0800 (PST)
Received: from emh03.mail.saunalahti.fi (emh03.mail.saunalahti.fi [62.142.5.109]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 116D91A1AAC for <tls@ietf.org>; Fri, 14 Nov 2014 22:05:59 -0800 (PST)
Received: from LK-Perkele-VII (a88-112-44-140.elisa-laajakaista.fi [88.112.44.140]) by emh03.mail.saunalahti.fi (Postfix) with ESMTP id 69360188793; Sat, 15 Nov 2014 08:05:56 +0200 (EET)
Date: Sat, 15 Nov 2014 08:05:56 +0200
From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
To: Oleg Gryb <oleg@gryb.info>
Message-ID: <20141115060555.GA18732@LK-Perkele-VII>
References: <54647819.3020802@polarssl.org> <2109273109.730596.1416005173738.JavaMail.yahoo@jws10656.mail.bf1.yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
In-Reply-To: <2109273109.730596.1416005173738.JavaMail.yahoo@jws10656.mail.bf1.yahoo.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
Sender: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Archived-At: http://mailarchive.ietf.org/arch/msg/tls/IqDhnZPy4sBIaaVEMcZfSmB8zyY
Cc: Manuel Pégourié-Gonnard <mpg@polarssl.org>, "tls@ietf.org" <tls@ietf.org>
Subject: Re: [TLS] Twist security for brainpoolp256r1
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: Sat, 15 Nov 2014 06:06:07 -0000

On Fri, Nov 14, 2014 at 10:46:13PM +0000, Oleg Gryb wrote:
> 
> > Openssl has a "speed" command that should be helpful. I'd expect a 
> > difference
> > higher than 30%.
> 
> 
> I had to change 'speed.c' in openssl to add barinpoolp256r1 (by default
> it simply not there). The difference for both ecdsa (signature) and ecdh
> (diffie-hellman-merkle key exchange) is less than 5%, so P-256 'optimization'
> in openssl is definitely overrated. I think, I'm good to go with Brainpool.

I did some quick benchmarking locally. The new code does ~2.4x(!) the number
of ECDH/ECDSA (all area accelerated by similar factor) ops per second compared
to the old.

(Intel i7 Ivy Bridge, so AVX but no AVX2).

> Doing 256 bit sign ecdsa's for 10s: 92012 256 bit ECDSA signs in 10.00s 
> Doing 256 bit verify ecdsa(nistp256)'s for 10s: 26294 256 bit ECDSA verify in 10.00s
> Doing 256 bit sign ecdsa's for 10s: 88745 256 bit ECDSA signs in 10.00s 
> Doing 256 bit verify ecdsa(brainpoolP256r1)'s for 10s: 24939 256 bit ECDSA verify in 10.00s
> 256 bit ecdsa (nistp256)   0.0001s   0.0004s   9201.2   2629.4
> 256 bit ecdsa (brainpoolP256r1)   0.0001s   0.0004s   8874.5   2493.9
> 
> Doing 256 bit  ecdh(nistp256)'s for 10s: 31820 256-bit ECDH ops in 10.00s
> Doing 256 bit  ecdh(brainpoolP256r1)'s for 10s: 29748 256-bit ECDH ops in 10.00s
> 256 bit ecdh (nistp256)   0.0003s   3182.0
> 256 bit ecdh (brainpoolP256r1)   0.0003s   2974.8

- What OpenSSL version that is based on?
- What build options?
- What CPU?

Those number don't pass my sanity checks if I assume new OpenSSL code:
- Difference between special prime and random prime is too small,
  hinting bad implementation of special prime.
- Extrapolation from numbers I got gives unreasonably low CPU speed.
 
If I estimate based on numbers I got (which is probably off for pre-AVX
or AVX2), I would estimate new p256 has about 2.5x the performance of
Brainpool.


-Ilari