All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Theodore Ts'o" <tytso@mit.edu>,
	"Ivan T . Ivanov" <iivanov@suse.de>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH v8 6/7] random: early initialization of ChaCha constants
Date: Thu, 30 Dec 2021 15:40:04 +0100	[thread overview]
Message-ID: <CAHmME9ogFn8deTmVMfKLjQ727kgGzuWRgaNaDW2PF+KwyQw0uQ@mail.gmail.com> (raw)
In-Reply-To: <20211229211009.108091-6-linux@dominikbrodowski.net>

Thanks for the patch. Comments are inline below.

On Wed, Dec 29, 2021 at 10:13 PM Dominik Brodowski
<linux@dominikbrodowski.net> wrote:
>  drivers/char/random.c   | 10 +++++++---
>  include/crypto/chacha.h | 15 +++++++++++----

For the next submission of this (which you can do standalone and call
a v2), please Cc linux-crypto and Herbert as part of the commit body.
I still intend to take this through the random tree, since that's the
purpose of it, but because it touches the lib/crypto code, they should
be in the loop.

>  static struct crng_state primary_crng = {
>         .lock = __SPIN_LOCK_UNLOCKED(primary_crng.lock),
> +       .state[0] = CHACHA_CONSTANT_EXPA, /* "expa" */
> +       .state[1] = CHACHA_CONSTANT_ND_3, /* "nd 3" */
> +       .state[2] = CHACHA_CONSTANT_2_BY, /* "2-by" */
> +       .state[3] = CHACHA_CONSTANT_TE_K, /* "te k" */
>  };

I don't think you need the comments here, since the constant is
already descriptive.

>
>  /*
> @@ -823,9 +827,9 @@ static void __maybe_unused crng_initialize_secondary(struct crng_state *crng)
>         crng->init_time = jiffies - CRNG_RESEED_INTERVAL - 1;
>  }
>
> -static void __init crng_initialize_primary(struct crng_state *crng)
> +static void __init crng_initialize_primary(void)
>  {
> +       struct crng_state *crng = &primary_crng;
> -       crng_initialize_primary(&primary_crng);
> +       crng_initialize_primary();

There are a bunch of places where we're passing around globals when we
could collapse them down. It probably makes sense to do that in a
separate cleanup series (please feel free!), rather than here, since
the init-time constants issue doesn't really change anything with
regards to this function signature.

>  static inline void chacha_init_consts(u32 *state)
>  {
> -       state[0]  = 0x61707865; /* "expa" */
> -       state[1]  = 0x3320646e; /* "nd 3" */
> -       state[2]  = 0x79622d32; /* "2-by" */
> -       state[3]  = 0x6b206574; /* "te k" */
> +       state[0]  = CHACHA_CONSTANT_EXPA; /* "expa" */
> +       state[1]  = CHACHA_CONSTANT_ND_3; /* "nd 3" */
> +       state[2]  = CHACHA_CONSTANT_2_BY; /* "2-by" */
> +       state[3]  = CHACHA_CONSTANT_TE_K; /* "te k" */
>  }

I don't think you need the comments here, since the constant is
already descriptive.

  reply	other threads:[~2021-12-30 14:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 19:04 [PATCH v6] random: fix crash on multiple early calls to add_bootloader_randomness() Dominik Brodowski
2021-12-28 14:06 ` Jason A. Donenfeld
2021-12-28 15:38   ` [PATCH v7 1/4] " Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 2/4] random: do not re-init if crng_reseed completes before primary init Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 3/4] random: do not throw away excess input to crng_fast_load Jason A. Donenfeld
2021-12-28 15:38     ` [PATCH v7 4/4] random: mix bootloader randomness into pool Jason A. Donenfeld
2021-12-29 21:10     ` [PATCH v8 1/7] random: fix crash on multiple early calls to add_bootloader_randomness() Dominik Brodowski
2021-12-29 21:10       ` [PATCH v8 2/7] random: do not re-init if crng_reseed completes before primary init Dominik Brodowski
2021-12-30 14:31         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 3/7] random: do not throw away excess input to crng_fast_load Dominik Brodowski
2021-12-30 14:32         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 4/7] random: mix bootloader randomness into pool Dominik Brodowski
2021-12-30 14:33         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 5/7] random: harmonize "crng init done" messages Dominik Brodowski
2021-12-30 14:34         ` Jason A. Donenfeld
2021-12-29 21:10       ` [PATCH v8 6/7] random: early initialization of ChaCha constants Dominik Brodowski
2021-12-30 14:40         ` Jason A. Donenfeld [this message]
2021-12-29 21:10       ` [PATCH v8 7/7] random: move crng_initialize_secondary to CONFIG_NUMA section Dominik Brodowski
2021-12-30  8:59         ` [PATCH v8.1 7/7] random: move NUMA-related code " Dominik Brodowski
2021-12-30 15:12           ` Jason A. Donenfeld
2021-12-30 15:14             ` [PATCH] random: use IS_ENABLED(CONFIG_NUMA) instead of ifdefs Jason A. Donenfeld
2021-12-31  8:27               ` Dominik Brodowski
2021-12-30 14:31       ` [PATCH v8 1/7] random: fix crash on multiple early calls to add_bootloader_randomness() Jason A. Donenfeld

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=CAHmME9ogFn8deTmVMfKLjQ727kgGzuWRgaNaDW2PF+KwyQw0uQ@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=iivanov@suse.de \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.