Re: [Cfrg] Poly1305 and timing attacks

David Jacobson <dmjacobson@sbcglobal.net> Mon, 10 March 2014 14:38 UTC

Return-Path: <dmjacobson@sbcglobal.net>
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 06FD21A0437 for <cfrg@ietfa.amsl.com>; Mon, 10 Mar 2014 07:38:14 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001] 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 FE6VAcBIe8Yd for <cfrg@ietfa.amsl.com>; Mon, 10 Mar 2014 07:38:10 -0700 (PDT)
Received: from nm8-vm7.access.bullet.mail.bf1.yahoo.com (nm8-vm7.access.bullet.mail.bf1.yahoo.com [216.109.114.182]) by ietfa.amsl.com (Postfix) with ESMTP id 09B981A0434 for <cfrg@irtf.org>; Mon, 10 Mar 2014 07:38:09 -0700 (PDT)
Received: from [66.196.81.157] by nm8.access.bullet.mail.bf1.yahoo.com with NNFMP; 10 Mar 2014 14:38:04 -0000
Received: from [98.138.226.242] by tm3.access.bullet.mail.bf1.yahoo.com with NNFMP; 10 Mar 2014 14:38:03 -0000
Received: from [127.0.0.1] by smtp113.sbc.mail.ne1.yahoo.com with NNFMP; 10 Mar 2014 14:38:03 -0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1394462283; bh=k7x1u4IRWiBh/qdSqlcGw6/J0uR48CuW/XPnsYwR/bk=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=QyOIRi+B+wlOKuzfmyS/eQrU3tFFuJYV1EHfSYyIwO6rTFXzTG/TqIuG8FZ3/Lgsb76oMWIcqMIuxi1MnsiidITHPbhjm6gnzzEy/zl9f4k+tEh1ZEE1pJTrAWQ2jgF0tODNNJTydRXX7lUQLGQoA4rO17R3gTvjUnSewqe0Ck0=
X-Yahoo-Newman-Id: 815261.98227.bm@smtp113.sbc.mail.ne1.yahoo.com
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: baGHNnYVM1niLrG0x31rspoa.IUayh9xTXwj1NfaSVzuC1Y ovrMizNG4a0rcCRYcRaqs.8JaltM335x7XcLLjHM.SvyOImLaeKm3T7G96oC dxF5Rfs99HILV8s79fTUflqNppu.kJxi9Fqjpab_ukaCOBWXqZ3pJ9sLwPtj W4PoWvJHppgasylESwCP1Om6yx6X5gn3QU_XZujhZr2JNCPj3uTruOaQZi.g r72BvO6O6oBaNw3imJ1LhHvqLi3xP14BoMtkfzetJ.nl0B0AIVcYL8RsJODg 9kIxiAzg1z3BuMgddSRezVbD5xv9UyRpNGEZI3DqUA8m7YMsICDNrPPQBMYu RmmpUDRYJHbbbt4rVXkMBe.Bavgfrif1_yebksDGtmwLTSXN3N4TGaLzuW6x Sd2AvKU5_WftGiZOU69lg.oZCxcYHNzrGDv_18l2I9BOjhxCmtBGYboinYyi Kmpm9wWznFh5EtvG_nBbQUxX.hjbt..hYyHpI6FWJ.qOcmzsLkxv3CpE1z.a BVgDTfgXcvtcRsHE6PE1dQJ02NkoWVLA73poTMvOHAHUnlutbAfIcJHVUPOI UuMBWcf0xxRU-
X-Yahoo-SMTP: nOrmCa6swBAE50FabWnlVFUpgFVJ9Gbi__8U5mpvhtQq7tTV1g--
X-Rocket-Received: from [192.168.1.64] (dmjacobson@99.120.97.155 with plain [98.138.84.52]) by smtp113.sbc.mail.ne1.yahoo.com with SMTP; 10 Mar 2014 14:38:03 +0000 UTC
Message-ID: <531DCE48.1010300@sbcglobal.net>
Date: Mon, 10 Mar 2014 07:38:00 -0700
From: David Jacobson <dmjacobson@sbcglobal.net>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: Yoav Nir <ynir.ietf@gmail.com>, Watson Ladd <watsonbladd@gmail.com>
References: <CAGvU-a7Mpn9Wrie=QEftsZrojQAcwysnQgNt5BOjdr8ZRY08Zg@mail.gmail.com> <CACsn0ckrTB37jB4Apj7GxAZUjou_=RUj7j4dgFeWpqxS4HKq6Q@mail.gmail.com> <CA0A4F63-89AB-4AC2-8955-E3C575E3B01C@gmail.com> <CACsn0cmNA15ZM9S2s73oTtKGH5SujSef9_3ez12jzg934HW9ow@mail.gmail.com> <CAGvU-a4m+ZVw6Gsq-_hPX_aLTajKkHD31G++otx5B-xu1vJ78g@mail.gmail.com>
In-Reply-To: <CAGvU-a4m+ZVw6Gsq-_hPX_aLTajKkHD31G++otx5B-xu1vJ78g@mail.gmail.com>
Content-Type: multipart/alternative; boundary="------------070204060401070109040600"
Archived-At: http://mailarchive.ietf.org/arch/msg/cfrg/U_Qt7_v3zjTReP5fKwdBl2qIqdw
Cc: "cfrg@irtf.org" <cfrg@irtf.org>
Subject: Re: [Cfrg] Poly1305 and timing attacks
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: Mon, 10 Mar 2014 14:38:14 -0000

On 3/10/14 6:19 AM, Yoav Nir wrote:
>
>
>
> On Mon, Mar 10, 2014 at 12:48 AM, Watson Ladd <watsonbladd@gmail.com 
> <mailto:watsonbladd@gmail.com>> wrote:
>
>     On Sun, Mar 9, 2014 at 3:00 PM, Yoav Nir <ynir.ietf@gmail.com
>     <mailto:ynir.ietf@gmail.com>> wrote:
>     >
>     > On Mar 9, 2014, at 6:45 PM, Watson Ladd <watsonbladd@gmail.com
>     <mailto:watsonbladd@gmail.com>> wrote:
>     <snipped agreement>
>     >
>     >> For Poly1305 as used in this draft, I am very, very hesitant about
>     >> approving any draft that says not-constant time is okay.
>     However, if
>     >> the entire keys are being generated pseudorandomly, then I
>     think, if
>     >> the side channel isn't gratuitously large, it's possibly safe.
>     Saying
>     >> anything more concrete would require a lot of painful analysis
>     of what
>     >> is leaked and how it can be used.
>     >>
>     >> Personally, I don't understand why making the crypto not constant
>     >> time, and thus open to attacks, simplifies the security
>     >> considerations. It might make the job of the implementor
>     easier, but
>     >> it makes the job of the person who builds on top harder.
>     >
>     > It makes the security considerations simpler because it makes
>     all the talk about constant time implementations go away and
>     eliminates the need for pointing people at how to accomplish this.
>     I agree I probably can't do this, as this implementation might
>     later be used as part of a library for other things. It's not
>     generally good to instruct people on how to make an implementation
>     with a warning label (that they will later ignore).
>
>     Well, I have to fundamentally disagree with this. A constant-time,
>     constant-memory access, constant-control flow implementation is far
>     more reassuring than one which doesn't have these properties. 
>
>
> Hey, no need to pile it on. You've already convinced me that the text 
> needs to stay.
>
> Do you have a reference I can point to on how to make the Poly1305 
> calculations constant-time?
>
> Yoav
>
>
> _______________________________________________
> Cfrg mailing list
> Cfrg@irtf.org
> http://www.irtf.org/mailman/listinfo/cfrg
I do want to disagree with this approach that everything should be 
constant time.

Sometimes the constant time approach is very onerous and inefficient.

For example, the binary method of inversion in a prime modulus field 
makes many data-dependent branches and the running time is not 
constant.  The constant time approach is to do a modular exponentiation 
to the p-2 power, which is very expensive.  But is is really easy to 
compute  b * inverse(b*x), where b is a randomly chosen blinding value.

In other cases it doesn't matter at all.

For example (and I mentioned this just a couple of days ago) consider 
the case of picking a random field element in a prime modulus field, 
were the modulus p is public.   Just pick random values less that the 
smallest power of 2 >= p-1  Repeat until you have a value < p.   That 
doesn't run in constant time, but it is perfectly safe.  The reason is 
that all it does is at worst reveal something about random numbers that 
you are not going to use. (Watson objected to this, but his objection 
was based on the distinctly different problem of getting a workable 
non-random value based on some other secret, as you might want to do for 
k in ECDSA.)

So in summary, I think it better to say that good crypto-engineering 
practice requires the avoidance of data-dependent branches and array 
indexes unless the data does not depend on any secret or is blinded.  
This is a simple rule that doesn't require complicated analysis.

     --David Jacobson