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: sm3: De-bloat sm3_block_generic()
Date: Tue, 24 Nov 2026 15:32:32 -0800 [thread overview]
Message-ID: <20261124233232.GF2001@quark> (raw)
In-Reply-To: <20261124085914.268803-1-ebiggers@kernel.org>
On Tue, Nov 24, 2026 at 12:59:14AM -0800, Eric Biggers wrote:
> sm3_block_generic() previously unrolled all 64 rounds, resulting in
> 13049 bytes of .text in lib/crypto/sm3.o, plus a 256-byte K[64] round
> constant table even though all round 0-15 constants are rotations of
> one value and all round 16-63 constants are rotations of one value.
>
> Therefore, roll up rounds 16-63 into 3 iterations of 16 rounds each, and
> generate the round constants on the fly via rotations.
>
> This reduces the .text size of lib/crypto/sm3.o from 13049 bytes to 7843
> bytes (a 40% reduction) and removes the 256-byte K[] table. A benchmark
> of this code showed no significant change in speed.
>
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> lib/crypto/sm3.c | 143 ++++++++++++++++-------------------------------
> 1 file changed, 48 insertions(+), 95 deletions(-)
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next
- Eric
prev parent reply other threads:[~2026-11-24 23:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 8:59 [PATCH] lib/crypto: sm3: De-bloat sm3_block_generic() Eric Biggers
2026-11-24 10:58 ` Ard Biesheuvel
2026-11-24 23:32 ` 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=20261124233232.GF2001@quark \
--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 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.