Re: [Cfrg] I-D Action: draft-nir-cfrg-chacha20-poly1305-01.txt

Mike Hamburg <mike@shiftleft.org> Thu, 13 March 2014 17:06 UTC

Return-Path: <mike@shiftleft.org>
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 120DC1A0499 for <cfrg@ietfa.amsl.com>; Thu, 13 Mar 2014 10:06:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 1.556
X-Spam-Level: *
X-Spam-Status: No, score=1.556 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FH_HOST_EQ_D_D_D_D=0.765, FH_HOST_EQ_D_D_D_DB=0.888, HELO_MISMATCH_ORG=0.611, HOST_MISMATCH_NET=0.311, RDNS_DYNAMIC=0.982, SPF_PASS=-0.001] autolearn=no
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 gzS0S9fyABow for <cfrg@ietfa.amsl.com>; Thu, 13 Mar 2014 10:06:04 -0700 (PDT)
Received: from aspartame.shiftleft.org (199-116-74-157-v301.PUBLIC.monkeybrains.net [199.116.74.157]) by ietfa.amsl.com (Postfix) with ESMTP id E170D1A08ED for <cfrg@irtf.org>; Thu, 13 Mar 2014 10:06:04 -0700 (PDT)
Received: from [192.168.1.147] (unknown [192.168.1.1]) by aspartame.shiftleft.org (Postfix) with ESMTPSA id 31B253AA3B; Thu, 13 Mar 2014 10:04:55 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shiftleft.org; s=sldo; t=1394730295; bh=U0V5fWxGio+HrF+nWvXILGqlOQXUzkaAbpQz/Bgp6r8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=TyAnvtYAZ1Tn3KOFqZktJgh+BER3o5S49gkDp1xsiLvS8KK0p6F2GFmpGPhQRPHsu sjGk0GyjVjw1s9noVDnGtWLVWkk3v2D43kWIIS/efcq4XB3ZoHErRO6fFGrrEXUOlq ySdA2CywApuLd4OTkHAjyG/68Z2i93g3HIMSNfRA=
Content-Type: text/plain; charset="windows-1252"
Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\))
From: Mike Hamburg <mike@shiftleft.org>
In-Reply-To: <9AB2F389-409D-408E-BAB6-000E74E6E43A@krovetz.net>
Date: Thu, 13 Mar 2014 10:05:55 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <CF20B966-98D7-4982-84C4-0E461C8ECA54@shiftleft.org>
References: <20140228121448.1c123bab@chromobil.localdomain> <1AC3290E-64A3-4D74-AE2B-C578236E60EA@krovetz.net> <411966EE-1A23-4B38-8A50-E479832CC13B@gmail.com> <9AB2F389-409D-408E-BAB6-000E74E6E43A@krovetz.net>
To: Ted Krovetz <ted@krovetz.net>
X-Mailer: Apple Mail (2.1874)
Archived-At: http://mailarchive.ietf.org/arch/msg/cfrg/ux5xaJgFXxdICrgymgz-5UOeRNk
Cc: cfrg@irtf.org
Subject: Re: [Cfrg] I-D Action: draft-nir-cfrg-chacha20-poly1305-01.txt
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: Thu, 13 Mar 2014 17:06:06 -0000

On Mar 13, 2014, at 8:16 AM, Ted Krovetz <ted@krovetz.net> wrote:

> 
>> I guess I should change the text to say that it’s a little-endian representation of integers limited to 32 bits.
> 
> I would recommend that you never use endianess to describe integers. An integer is an integer, and endianess has only to do with cpu-memory interfacing. An integer can be read little-endian from memory, but the resulting integer is not a little-endian integer, it's just an integer.

I probably would have said "little-endian integer" too, but this suggestion is clearer.

> So, for example, the input to chacha is a 256-bit key string, 96-bit nonce string and 32-bit unsigned integer. The first thing that happens in chacha is the key and nonce are split into 32-bit unsigned integers by byte reversing each 32-bit chunk and then interpreting each 32-bit chunk as an unsigned integer. Now we're in the realm of integers, and the word endianess is never mentioned.


I don't like this, though.  Your target is software on computers that use octets, right?  In that case, the key contains 32 octets, and the nonce contains 12 octets.  The first thing that happens is that the key and nonce are split into 4-octet fields, which are then converted to unsigned 32-bit integers by interpreting them in little-endian order, that is, with least significant octet first.

On a computer that uses 32-bit unsigned integer words as the addressable unit instead of octets (eg, a DSP), the input is an 8-word key and a 3-word nonce, and there's no endian issue.  That's why it's tempting to say "little-endian integers" even though it's less clear: it specifies the input on multiple platforms simultaneously.

I say this because "interpreting each 32-bit chunk as an unsigned integer" is ambiguous.  The natural meaning is "according to the platform's endian" which is not what you want.

-- Mike