From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH] random: initialize ChaCha20 constants with correct endianness
Date: Fri, 18 Sep 2020 16:42:07 -0400 [thread overview]
Message-ID: <20200918204207.GC80112@mit.edu> (raw)
In-Reply-To: <20200916045013.142179-1-ebiggers@kernel.org>
On Tue, Sep 15, 2020 at 09:50:13PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> On big endian CPUs, the ChaCha20-based CRNG is using the wrong
> endianness for the ChaCha20 constants.
>
> This doesn't matter cryptographically, but technically it means it's not
> ChaCha20 anymore. Fix it to always use the standard constants.
I'll note that we're not technically ChaCha20 in terms of how we
handle the IV. ChaCha20 is defined as having a 96 bit IV and a 32-bit
counter. The counter is "usually initialized to be zero or one" (per
RFC 7539) and the counter is defined to be Little Endian.
We're currently not bothering to deal with Endian conversions with the
counter, and we're using a 64-bit counter, instead of a 32-bit
counter. We also twiddle 32-bits of the state (crng->state[14]) by
XOR'ing it with RDRAND if available at each round, which is also a
spec violation.
WE also initialize the counter to be a random value, using the
input_pool or the primary crng state (if we are initializing the
secondary state), but given that the specification says _usually_ zero
or one, that's not an out-and-out spec violation.
As far as the other deviations / "spec violations" from ChaCha-20 are
concerned... I'm "sorry not sorry". :-)
I have no objections to changing things so that the first 4 words of
the crng state are more ChaCha-20-like, on the theory that most of the
cryptoanlysis work (both positive and negative) have been done with
the little-endian version of "expand 32-byte k". I don't think it
really makes a difference, either positively or negatively. But
technically we'd *still* not be using ChaCha20. We could say that
we're using the ChaCha20 block function, regardless.
Cheers,
- Ted
next prev parent reply other threads:[~2020-09-18 20:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 4:50 [PATCH] random: initialize ChaCha20 constants with correct endianness Eric Biggers
2020-09-17 8:12 ` Herbert Xu
2020-09-18 20:42 ` Theodore Y. Ts'o [this message]
2020-09-18 21:57 ` Eric Biggers
2020-10-07 3:51 ` Eric Biggers
2020-10-26 16:33 ` Eric Biggers
2020-11-20 18:52 ` Eric Biggers
2021-01-04 18:56 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200918204207.GC80112@mit.edu \
--to=tytso@mit.edu \
--cc=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).