perf util: add a basic SHA-1 implementation
authorEric Biggers <ebiggers@kernel.org>
Wed, 25 Jun 2025 20:23:09 +0000 (13:23 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 26 Jun 2025 17:51:40 +0000 (10:51 -0700)
commit43830468b6436811ff732b062f8d6306c6eddb77
tree42fcba7d87eeaf1de9817eb5ff4054f7473cd4d5
parent55a18d2f3ff79c9082225f44e0abbaea6286bf99
perf util: add a basic SHA-1 implementation

SHA-1 can be written in fewer than 100 lines of code.  Just add a basic
SHA-1 implementation so that there's no need to use an external library
or try to pull in the kernel's SHA-1 implementation.  The kernel's SHA-1
implementation is not really intended to be pulled into userspace
programs in the way that it was proposed to do so for perf
(https://lore.kernel.org/r/20250521225307.743726-3-yuzhuo@google.com/),
and it's also likely to undergo some refactoring in the future.  There's
no need to tie userspace tools to it.

Include a test for sha1() in the util test suite.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250625202311.23244-3-ebiggers@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/util.c
tools/perf/util/Build
tools/perf/util/sha1.c [new file with mode: 0644]
tools/perf/util/sha1.h [new file with mode: 0644]