Subject: Re: [CFRG] XChacha20 counter size

From: "D. J. Bernstein" <[email-masked]>
Date: 2 Jan 2021 18:20:10 -0000

A few comments.

1. For people designing high-level protocols, it's good to split
messages into separately authenticated limited-length packets, for
several reasons explained here:

   https://groups.google.com/forum/#!original/boring-crypto/BpUmNMXKMYQ/EEwAIeQdjacJ

One of the reasons is that the code handling packets is generally tested
only for limited lengths; testing many lengths is expensive.

2. For people designing low-level formats (network formats, C integer
sizes, etc.), upgrading 32-bit counters to 64-bit counters is good
practice, since 32-bit counters often overflow. Occasionally this can be
overridden by other considerations, but it's the safest default.

3. #2 doesn't mean that everything else will work with 64-bit counters;
it's just one step towards eliminating 32-bit limitations. (For example,
changing "int" to "long long" in the OpenSSL external APIs won't make
all sorts of internal 32-bit quantities turn into 64 bits.) Also, even
if everything is 64-bit clean, there are other reasons for #1.

4. Conversely, #1 doesn't remove the reasons for #2: one doesn't want
the #1 design decisions embedded into all the #2 pieces of the system.
This is a matter of information hiding.

---Dan