From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [v2 PATCH] crypto: chacha - Add DEFINE_CHACHA_STATE macro
Date: Tue, 7 Jul 2020 19:31:08 -0700 [thread overview]
Message-ID: <20200708023108.GK839@sol.localdomain> (raw)
In-Reply-To: <20200706223716.GA10958@gondor.apana.org.au>
On Tue, Jul 07, 2020 at 08:37:16AM +1000, Herbert Xu wrote:
> On Mon, Jul 06, 2020 at 12:07:17PM -0700, Eric Biggers wrote:
> >
> > This changes chacha_state to be a pointer, which breaks clearing the state
> > because that uses sizeof(chacha_state):
> >
> > memzero_explicit(chacha_state, sizeof(chacha_state));
> >
> > It would need to be changed to use CHACHA_BLOCK_SIZE.
>
> Good catch. Thanks! Here's an update:
>
> ---8<---
> As it stands the chacha state array is made 12 bytes bigger on
> x86 in order for it to be 16-byte aligned. However, the array
> is not actually aligned until it hits the x86 code.
>
> This patch moves the alignment to where the state array is defined.
> To do so a macro DEFINE_CHACHA_STATE has been added which takes
> care of all the work to ensure that it is actually aligned on the
> stack.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Hmm, __chacha20poly1305_encrypt() already uses:
memzero_explicit(chacha_state, CHACHA_STATE_WORDS * sizeof(u32));
That's equivalent to CHACHA_BLOCK_SIZE now, but it would be best to use the same
constant everywhere. Can you pick one or the other to use?
Also, in chacha20poly1305-selftest.c there's a state array that needs to be
converted to use the new macro:
u32 chacha20_state[CHACHA_STATE_WORDS];
- Eric
next prev parent reply other threads:[~2020-07-08 2:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 13:37 [PATCH] crypto: chacha - Add DEFINE_CHACHA_STATE macro Herbert Xu
2020-07-06 19:07 ` Eric Biggers
2020-07-06 22:37 ` [v2 PATCH] " Herbert Xu
2020-07-08 2:31 ` Eric Biggers [this message]
2020-07-08 2:44 ` [v3 " Herbert Xu
2020-07-08 5:46 ` Ard Biesheuvel
2020-07-08 6:28 ` Ard Biesheuvel
2020-07-08 6:54 ` Martin Willi
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=20200708023108.GK839@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@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).