[Cfrg] changes to hunt-and-peck algorithm (Re: Requesting removal of CFRG co-chair)

David McGrew <mcgrew@cisco.com> Fri, 03 January 2014 22:45 UTC

Return-Path: <mcgrew@cisco.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 E7AD91AE005; Fri, 3 Jan 2014 14:45:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -15.039
X-Spam-Level:
X-Spam-Status: No, score=-15.039 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, RP_MATCHES_RCVD=-0.538, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5] 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 k-kS9gg4qEUL; Fri, 3 Jan 2014 14:45:20 -0800 (PST)
Received: from rcdn-iport-7.cisco.com (rcdn-iport-7.cisco.com [173.37.86.78]) by ietfa.amsl.com (Postfix) with ESMTP id 166BE1ADFFF; Fri, 3 Jan 2014 14:45:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5375; q=dns/txt; s=iport; t=1388789113; x=1389998713; h=message-id:date:from:mime-version:to:cc:subject: references:in-reply-to:content-transfer-encoding; bh=Kw8y1+M7uIrkYXZJhOtoirR1oPQRHwHchvdCNJTtNOQ=; b=iTZiAfhep9adNZ6vNUhI0MxRCbBxlKUGwvXd/ZFHCN9/+xJKBtV8Eoa0 OxH7jJUGbzF/w22iYJm0lGc0z2zvahRn3orNUloWzDjzzib5+3s4gvb8F NpEcIPLU/N3VNVeHyIdld2xW+gtSCfND24g7H+7I55/sS5NrDxB9jHxzk 0=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AgMFAMc8x1KtJXHB/2dsb2JhbABYgws4uXyBDBZ0giUBAQEEOEABEBkKCQ8HDwkDAgECAUUGDQEHAgUSh2kNwx0XjiEcAQFPBxiEHwEDiUOOVIZFi0+Bb4FcHoE1
X-IronPort-AV: E=Sophos;i="4.95,600,1384300800"; d="scan'208";a="295142277"
Received: from rcdn-core2-6.cisco.com ([173.37.113.193]) by rcdn-iport-7.cisco.com with ESMTP; 03 Jan 2014 22:45:12 +0000
Received: from [10.0.2.15] (rtp-mcgrew-8913.cisco.com [10.117.10.228]) by rcdn-core2-6.cisco.com (8.14.5/8.14.5) with ESMTP id s03MjArY014458; Fri, 3 Jan 2014 22:45:11 GMT
Message-ID: <52C73927.9020802@cisco.com>
Date: Fri, 03 Jan 2014 17:26:47 -0500
From: David McGrew <mcgrew@cisco.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9
MIME-Version: 1.0
To: Trevor Perrin <trevp@trevp.net>
References: <CAGZ8ZG2f9QHX40RcB8aajWvEfG0Gh_uewu2Rq7bQGHYNx6cOmw@mail.gmail.com> <52B91820.9090706@cisco.com> <CAGZ8ZG02+o=Qm0gUQiVF9H_=wfn+wQt8ahY1ntLHNsELXbvtVg@mail.gmail.com> <52B9CB13.9020500@cisco.com> <CAGZ8ZG07QGL4mD1+XpDgm-5GHuhZEg2WRUvF20zRM_ZPNFLOUQ@mail.gmail.com>
In-Reply-To: <CAGZ8ZG07QGL4mD1+XpDgm-5GHuhZEg2WRUvF20zRM_ZPNFLOUQ@mail.gmail.com>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
Cc: "cfrg@irtf.org" <cfrg@irtf.org>, irtf-chair@irtf.org
Subject: [Cfrg] changes to hunt-and-peck algorithm (Re: Requesting removal of CFRG co-chair)
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: Fri, 03 Jan 2014 22:45:23 -0000

Hi Trevor,

On 12/27/2013 10:56 AM, Trevor Perrin wrote:
>
> I'm still not sure what you're asking.  Let's just look at a crude
> analysis of the "40-loops" countermeasure Kevin endorsed, comparing
> CFRG draft-00 vs draft-01/draft-02.
>
> Let's assume that modular square roots are calculated via modular
> exponentiation, and that Legendre symbol calculations take less time.
> Let's also ignore the variable time taken by a Legendre symbol
> calculation and other conditional logic, and just count the number of
> ops.
>
> In draft-00, the hunt-and-peck loop in 3.2.1 performs Legendre symbol
> calculations until it finds a square (probability ~1/2), at which
> point a square root is performed.  So:
>   - 1 modular exponentiation
>   - Variable number of Legendre symbol calculations
>     - geometric distribution with mean ~2, variance ~2
>
> In draft-01 and draft-02, the hunt-and-peck loop continues until it
> completes 40 loops, with a probability ~1/2 of performing a modular
> exponentiation on each iteration.  So:
>   - Variable number of modular exponentiations
>     - binomial distribution with mean ~20, variance ~10
>   - 40 Legendre symbol calculations
>
> The 40-loops algorithm was intended to reduce timing variance but
> instead increases it, and increases computation cost as well.  So I
> think "ineffective" is a fair description.  Do you agree?
>

I compared version 00 against version 01 using the IETF diff tool:

http://www.ietf.org/rfcdiff?url1=draft-irtf-cfrg-dragonfly-00&difftype=--html&submit=Go!&url2=draft-irtf-cfrg-dragonfly-01

The only change in the algorithm that you cite (Sections 3.2.1 and 
3.2.2.) is the change in the conditional statement that you mention.

If  the condition "((x^3 + ax + b) is a quadratic residue mod p)" is 
checked using an efficient method such as the legendre/jacobi symbol, 
which takes significantly less time than the execution of the branch "y 
= sqrt(x^3 + ax + b)", then the number of times that the branch executes 
will be detectable to an attacker.   This will give an attacker 
information about the password.   So in this case, I agree, versions 01 
and 02 seem more vulnerable than version 00 to timing attacks.

But an alternative way to implement the algorithm would be to use Shanks 
method for computing square roots mod p, or an algorithm like it, which 
upon termination either outputs the square root or an indication that 
the number that was input is not a quadratic residue.   In this case, 
version 01 could be less vulnerable to timing attacks than version 00.   
(I would guess this is what Dan had in mind.)

Clearly, this algorithm is not specified well enough in the draft to 
ensure that it will be implemented in a way that resists timing 
attacks.   Additionally, the most efficient way to implement the 
algorithm in the draft (using the legendre symbol) would lead to 
vulnerabilities.   These are significant problems.

On the subject of Kevin's influence, here is the timeline:

Dec 13 2012.   Kevin summarizes the Dragonfly status, asks for input, 
and is the first person to describe the need for Dragonfly to resist 
timing attacks.   He proposed a solution.   Scott Fluhrer pointed out a 
problem with the proposal, and suggests instead the "40 loop" fix.

Dec 17.   Kevin again summarizes the Dragonfly status, suggests adopting 
Scott's fix, and calls for feedback.   Dan Harkins responds that 
draft-tls-pwd (a different specification of Dragonfly) already has an 
equivalent fix.

Dec 18 2012.   Scott points out that the Dragonfly spec needs to be more 
clear on its use of the fix, and suggests computing the legendre/jacobi 
symbol instead of computing an actual square root.

However, Scott's suggestions were not picked up in 
draft-irtf-cfrg-dragonfly.   In retrospect, it seems that Dan did not 
understand the points that Scott was trying to make, and there was no 
follow up from anyone in the RG to make sure that the changes had been 
done, quite possibly because people assumed that the fix actually was 
equivalent.    Scott has clarified on the list recently, with the 
essential point being that the square root computation can be moved 
outside of the while loop.  (As a side note: it would simplify this 
computation if p = 3 (mod 4).)

I suspect that Dan is assuming that something like Shank's method will 
be used.   Your analysis assumes that the Legendre/Jacobi symbol will be 
used.    Note, however, that the suggestion to use that computational 
method came after Kevin's suggestion to use the "40 loop" fix.

Having participated in some of the off list conversations about 
Dragonfly, and having recently reviewed the discussions on the mail 
list, it seems to me that Kevin's input was an effort to promote 
positive changes, review, and discussion, and not an attempt to subvert 
the protocol.    I note that Kevin was the first to point out that 
resisting timing attacks was a goal, and he called for review 
repeatedly.   If he had wanted to influence the protocol without 
arousing suspicion, a far more effective way to have done that would 
have been to send private emails to Dan asking for changes to the draft.

If you have more questions about what Kevin did and why, please direct 
them to him.

regards,

David