Re: [Cfrg] ChaCha20 and Poly1305 for IPsec

David McGrew <> Tue, 07 January 2014 00:20 UTC

Return-Path: <>
Received: from localhost ( []) by (Postfix) with ESMTP id 744DC1AE364 for <>; Mon, 6 Jan 2014 16:20:12 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -15.039
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id 6IHwjHmGu3U9 for <>; Mon, 6 Jan 2014 16:20:08 -0800 (PST)
Received: from ( []) by (Postfix) with ESMTP id CF6F61AD9AE for <>; Mon, 6 Jan 2014 16:20:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;; l=5289; q=dns/txt; s=iport; t=1389053999; x=1390263599; h=message-id:date:from:mime-version:to:cc:subject: references:in-reply-to:content-transfer-encoding; bh=TiNct4RZ87ZI3cUNzdXws8gizC5d3Qq4kH/4YJuR5J0=; b=JdRlVitVSjOpmwfHcINUJgMStC684PiYvnc07orjOUfqBZPNHCqdIbwv MX1rlvTuo3kk0IVe78rFueNN7e1IFUZljnc3Qv4tBhlTS7KymDnYVm2L9 sBbU4+3IlWFKFx0nwPILRtPi6sdF5/fqfPmUjMhauHEEgUwUDF3WxqXs3 g=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-AV: E=Sophos;i="4.95,615,1384300800"; d="scan'208";a="295585007"
Received: from ([]) by with ESMTP; 07 Jan 2014 00:19:59 +0000
Received: from [] ( []) by (8.14.5/8.14.5) with ESMTP id s070Jvb2016906; Tue, 7 Jan 2014 00:19:57 GMT
Message-ID: <>
Date: Mon, 06 Jan 2014 19:19:57 -0500
From: David McGrew <>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9
MIME-Version: 1.0
To: Yoav Nir <>
References: <> <> <> <> <>
In-Reply-To: <>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: "" <>, Adam Langley <>
Subject: Re: [Cfrg] ChaCha20 and Poly1305 for IPsec
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Crypto Forum Research Group <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 07 Jan 2014 00:20:12 -0000

Hi Yoav,

On 01/06/2014 06:43 PM, Yoav Nir wrote:
> On Jan 7, 2014, at 1:00 AM, David McGrew <>
>   wrote:
>> Hi Yoav,
>> On 01/06/2014 05:23 PM, Yoav Nir wrote:
>>> Thanks. Proposing this seems so obvious, that I thought I must be missing something that makes it unsuitable.
>>> On Jan 6, 2014, at 8:05 PM, Adam Langley <> wrote:
>>>> On Sun, Jan 5, 2014 at 11:18 AM, Yoav Nir <> wrote:
>>>>> Unlike RC4, ChaCha20 has a 64-bit nonce, so different packets could use different keystreams, much like block ciphers in counter mode. Unlike 3DES, ChaCha20 has performance that is close to that of AES.
>>>>> So my question is whether there is any reason not to use ChaCha20 (with or without the AEAD construction from Adam's draft) for IKE and/or IPsec. Could this be the standby algorithm that we have been looking for?
>>>> I don't know of any problems with this. If IPsec has the concept of a
>>>> counter than can be used as an nonce then I think the AEAD
>>>> construction would be fine, as is.
>>> IPsec has a 32- or 64-bit packet counter, but for some reason it has never been used as a nonce. Both AES-CTR and AES-GCM have explicit 64-bit IVs in IPsec, so I think a ChaCha implementation should do the same - have an explicit IV that's used as a nonce, with a MUST requirement for uniqueness of IV/key combination.
>> the reason that the ESP sequence number isn't used as a cryptographic nonce is that it was not regarded as reliable enough.   That is, the ESP standard does not insist that the sequence number never wrap, and many implementations are not careful about maintaining the uniqueness of the sequence number.  This situation is not ideal, but it does seem to be the case.
> I agree that the text could use some more RFC2119 language, but allowing the sequence to wrap is not allowed:
>                                                If anti-replay is enabled
>     (the default), the transmitted Sequence Number must never be allowed
>     to cycle.  Thus, the sender's counter and the receiver's counter MUST
>     be reset (by establishing a new SA and thus a new key) prior to the
>     transmission of the 2^32nd packet on an SA.
>>>> If one needs to pick the nonces
>>>> randomly, however, then a 64-bit space is too small and XChaCha (which
>>>> has a 192-bit nonce) would be more suitable.
>>> It would work, but IPsec requires re-keying when the 32-bit or 64-bit counter reaches 2^n-1, so that seems like overkill.
>> Agreed that a 192-bit nonce sounds a bit big.
>> ESP supports multipoint security associations, in which case it is essential to coordinate nonces across all of the encrypters, to make sure that they are all distinct.   The requirements and a simple approach is outlined in rfc6054, and those requirements are followed in the latest version of the Group Domain of Interpretation rfc6407.  The nonce management is a bit ugly, but there is precedent for it.
>> We could do a lot worse than ChaCha as a cipher.   An AEAD construction could be used in a way that mirrors GCM/CCM, though if I recall right, Adam defined an 8-byte nonce rather than a 12-byte nonce for the ChaCha AEAD algorithm, which makes it incompatible with almost all of the other AEAD algorithms (see Table 1 of draft-mcgrew-iv-gen-02).   A 12-byte nonce would enable ESP implementations to use the same nonce generation techniques, including rfc6407 ones.
> An 8-byte nonce is part of ChaCha.

  - faceplam -  Yes, of course.

> This is different from counter mode where the initial counter could be anything up to block size. I don't claim to understand why ChaCha has a 64-bit nonce and a 64-bit block counter instead of, say, a 96-bit nonce and a 32-bit block counter (good for 256 GB - plenty for an IP packet). Would ChaCha modified like that retain its security properties?

I think so - I would be surprised if it didn't retain its security 
properties.   But it might be best to avoid tweaking the design.

>> My biggest concern with ChaCha is: will it have the global credibility that we need?    If we think that it does, we should go about documenting the work that has been done analyzing it.  The record of the analysis will become extremely important once the cipher gets picked up by the semi-technical press and the user community.
> That sounds like a good task for CFRG. As some have mentioned in previous threads, we can't trust NIST for all our crypto needs.

That makes sense to me, but I would also much like to hear other opinions.


> This is not that they're evil, but more in that they're reluctant to endorse something that didn't originate with them (GCM was a fluke). So we have to rely on other sources.
>> Since so much of ESP is point to point and works at a high data rate, it makes sense to think about counter-based nonces and throughput-optimized algorithms, like ChaCha.   Algorithms that are misuse-resistant would be useful in scenarios other than point-to-point ones, and in my opinion are also worth considering as future work for ESP.
>> David
> _______________________________________________
> Cfrg mailing list
> .