[PATCH 11/12] crypto: sm3 - Remove the original "sm3_block_generic()"

Eric Biggers ebiggers at kernel.org
Fri Mar 20 21:09:34 PDT 2026


Since the architecture-optimized SM3 code was migrated into lib/crypto/,
sm3_block_generic() is no longer called.  Remove it.  Then, since this
frees up the name, rename sm3_transform() to sm3_block_generic()
(matching the naming convention used in other hash algorithms).

Signed-off-by: Eric Biggers <ebiggers at kernel.org>
---
 include/crypto/sm3.h |  2 --
 lib/crypto/sm3.c     | 19 +++----------------
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/include/crypto/sm3.h b/include/crypto/sm3.h
index 702c5326b4be..34d7eb32b7db 100644
--- a/include/crypto/sm3.h
+++ b/include/crypto/sm3.h
@@ -29,12 +29,10 @@ struct sm3_state {
 	u32 state[SM3_DIGEST_SIZE / 4];
 	u64 count;
 	u8 buffer[SM3_BLOCK_SIZE];
 };
 
-void sm3_block_generic(struct sm3_state *sctx, u8 const *data, int blocks);
-
 /* State for the SM3 compression function */
 struct sm3_block_state {
 	u32 h[SM3_DIGEST_SIZE / 4];
 };
 
diff --git a/lib/crypto/sm3.c b/lib/crypto/sm3.c
index 20500cf4b8c0..b02b8a247adf 100644
--- a/lib/crypto/sm3.c
+++ b/lib/crypto/sm3.c
@@ -77,12 +77,12 @@ static const u32 ____cacheline_aligned K[64] = {
 			^ W[(i-9) & 0x0f]		\
 			^ rol32(W[(i-3) & 0x0f], 15))	\
 		^ rol32(W[(i-13) & 0x0f], 7)		\
 		^ W[(i-6) & 0x0f])
 
-static void sm3_transform(struct sm3_block_state *state,
-			  const u8 data[SM3_BLOCK_SIZE], u32 W[16])
+static void sm3_block_generic(struct sm3_block_state *state,
+			      const u8 data[SM3_BLOCK_SIZE], u32 W[16])
 {
 	u32 a, b, c, d, e, f, g, h, ss1, ss2;
 
 	a = state->h[0];
 	b = state->h[1];
@@ -175,30 +175,17 @@ static void sm3_transform(struct sm3_block_state *state,
 #undef R2
 #undef I
 #undef W1
 #undef W2
 
-void sm3_block_generic(struct sm3_state *sctx, u8 const *data, int blocks)
-{
-	u32 W[16];
-
-	do {
-		sm3_transform((struct sm3_block_state *)sctx->state, data, W);
-		data += SM3_BLOCK_SIZE;
-	} while (--blocks);
-
-	memzero_explicit(W, sizeof(W));
-}
-EXPORT_SYMBOL_GPL(sm3_block_generic);
-
 static void __maybe_unused sm3_blocks_generic(struct sm3_block_state *state,
 					      const u8 *data, size_t nblocks)
 {
 	u32 W[16];
 
 	do {
-		sm3_transform(state, data, W);
+		sm3_block_generic(state, data, W);
 		data += SM3_BLOCK_SIZE;
 	} while (--nblocks);
 
 	memzero_explicit(W, sizeof(W));
 }
-- 
2.53.0




More information about the linux-riscv mailing list