Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: [PATCH] lib/crypto: x86/blake2s: Permute original message words in AVX-512 code
Date: Fri, 13 Nov 2026 20:25:20 -0800	[thread overview]
Message-ID: <20261114042520.GF2025@sol> (raw)
In-Reply-To: <20261112042513.59919-1-ebiggers@kernel.org>

On Wed, Nov 11, 2026 at 08:25:13PM -0800, Eric Biggers wrote:
> Each round of BLAKE2s takes a different fixed permutation of the message
> words as an input.  For each round, blake2s_compress_avx512() applies
> that permutation on the message words in %ymm6-%ymm7, writing the
> permuted words to %ymm8-%ymm9 where they are used for the round.
> 
> Oddly, though, it also copies the permuted words back into %ymm6-%ymm7.
> That means the next round has to apply the previous round's inverse
> permutation, then the next round's permutation.  Which it does, by using
> the 'sigma2' table which has the permutations precomposed in this way.
> 
> However, this is not necessary at all, as we can simply do each round's
> permutation on the original message words, using the 'sigma' table which
> is already present in the file for blake2s_compress_ssse3().
> 
> Do that instead.  This eliminates 160 unnecessary bytes of rodata, two
> unnecessary instructions per round, and a loop-carried dependency.
> 
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
>  lib/crypto/x86/blake2s-core.S | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric

      parent reply	other threads:[~2026-11-14  4:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  4:25 [PATCH] lib/crypto: x86/blake2s: Permute original message words in AVX-512 code Eric Biggers
2026-11-13  8:28 ` Ard Biesheuvel
2026-11-14  4:25 ` Eric Biggers [this message]

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=20261114042520.GF2025@sol \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@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