linux/tools/perf/util/sha1.h
Eric Biggers 43830468b6 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>
2025-06-26 10:51:40 -07:00

6 lines
166 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <linux/types.h>
#define SHA1_DIGEST_SIZE 20
void sha1(const void *data, size_t len, u8 out[SHA1_DIGEST_SIZE]);