Re: [PATCH 03/26] lib/crypto: sha1: Add SHA-1 library functions

From
Eric Biggers <ebiggers@kernel.org>
Date
2025-07-13 16:54:04
Also in
linux-arm-kernel, linux-crypto, linux-mips, linux-s390, lkml, sparclinux
Reply to
Elliott, Robert (Servers), 2025-07-13
On Sun, Jul 13, 2025 at 03:05:16PM +0000, Elliott, Robert (Servers) wrote:
quoted
-----Original Message-----
From: Eric Biggers <ebiggers@kernel.org>
Sent: Saturday, July 12, 2025 6:23 PM
Subject: [PATCH 03/26] lib/crypto: sha1: Add SHA-1 library functions
...
quoted
+static void __maybe_unused sha1_blocks_generic(struct sha1_block_state
*state,
+					       const u8 *data, size_t nblocks)
+{
+	u32 workspace[SHA1_WORKSPACE_WORDS];
+
+	do {
+		sha1_transform(state->h, data, workspace);
+		data += SHA1_BLOCK_SIZE;
+	} while (--nblocks);
+
+	memzero_explicit(workspace, sizeof(workspace));
+}
That assumes the caller will never pass nblocks of 0... should that be
checked first?
No.  This is a static function, and it's easy to verify that all callers
pass a positive nblocks.  All these code paths are also well-covered by
sha1_kunit.  Also, lib/crypto/sha256.c and lib/crypto/sha512.c do the
exact same thing.  Also, most of the architecture-specfiic
implementations of sha{1,256,512}_blocks() assume positive nblocks too.

- Eric
Thread (31 messages) 31 messages, 3 authors, last reply 2025-07-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help