Re: [hybi] AES-CTR is darned fast (was Re: Masking overhead with measurements and code)

Willy Tarreau <w@1wt.eu> Sun, 09 January 2011 20:49 UTC

Return-Path: <w@1wt.eu>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 924713A6845 for <hybi@core3.amsl.com>; Sun, 9 Jan 2011 12:49:56 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.085
X-Spam-Level:
X-Spam-Status: No, score=-2.085 tagged_above=-999 required=5 tests=[AWL=-0.042, BAYES_00=-2.599, HELO_IS_SMALL6=0.556]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f6AtiV81-m2s for <hybi@core3.amsl.com>; Sun, 9 Jan 2011 12:49:55 -0800 (PST)
Received: from 1wt.eu (1wt.eu [62.212.114.60]) by core3.amsl.com (Postfix) with ESMTP id 73E1C3A6814 for <hybi@ietf.org>; Sun, 9 Jan 2011 12:49:54 -0800 (PST)
Received: (from willy@localhost) by mail.home.local (8.14.4/8.14.4/Submit) id p09Kq2QH009718; Sun, 9 Jan 2011 21:52:02 +0100
Date: Sun, 09 Jan 2011 21:52:02 +0100
From: Willy Tarreau <w@1wt.eu>
To: Maciej Stachowiak <mjs@apple.com>
Message-ID: <20110109205202.GT5743@1wt.eu>
References: <20110108111632.GI2479@1wt.eu> <1294531527.7650.535.camel@ds9.ducksong.com> <56F80FB9-DAAD-40CA-92E8-21390546851B@apple.com> <20110109143423.GM5743@1wt.eu> <BDA504E6-A722-4513-A660-467E22140958@apple.com> <20110109200346.GR5743@1wt.eu> <DB77A28F-CE0C-4AAF-AB4E-7DBE06D4D1D8@apple.com> <20110109202827.GS5743@1wt.eu> <AB4429EC-1F62-483A-8731-33343B096DA0@apple.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <AB4429EC-1F62-483A-8731-33343B096DA0@apple.com>
User-Agent: Mutt/1.4.2.3i
Cc: "hybi@ietf.org" <hybi@ietf.org>
Subject: Re: [hybi] AES-CTR is darned fast (was Re: Masking overhead with measurements and code)
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 09 Jan 2011 20:49:56 -0000

On Sun, Jan 09, 2011 at 12:34:37PM -0800, Maciej Stachowiak wrote:
> 
> On Jan 9, 2011, at 12:28 PM, Willy Tarreau wrote:
> 
> > On Sun, Jan 09, 2011 at 12:22:22PM -0800, Maciej Stachowiak wrote:
> >> I think your conclusion here is wrong. AES-CTR does not repeat the key
> >> schedule on any fixed cycle, as I understand it.
> > 
> > I've never said that. The fact that it *does not* repeat the key
> > precisely is what makes it harder to get the expected pattern.
> > 
> >> It generates a psuedorandom non-repeating keystream.
> > 
> > Exactly. And in a pseudorandom keystream, a given 32-bit pattern
> > will appear once in 16GB, and could appear once in a cleaverly
> > built 4GB stream too.
> 
> There's no way to guarantee that a chosen 32-bit pattern will appear anywhere in AES-CTR output for an attacker-controlled input. It could appear 0 times, no matter what the input is. So your claim is false.

That's the principle of randomness. A typical pseudo-random should make
any pattern appear. Of course it is possible that it does not appear, but
the probability to see the pattern at least once in a perfectly random
series of 2^32 patterns is of 1-(1-1/(2^32))^(2^32) = 1-1/e = 63%. It's
already 39% in half the patterns and becomes 86% in the double of the
patterns.

Regards,
Willy