From 75b6d96e139c65ba457120d04767a3fc1b948372 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 17 Sep 2023 03:31:23 -0400 Subject: add tests/fuzz --- tests/fuzz/Makefile | 21 +++++++++++++++++++++ tests/fuzz/README.md | 6 ++++++ tests/fuzz/fuzz.c | 7 +++++++ tests/fuzz/sha3.c | 1 + tests/fuzz/sha3.h | 1 + 5 files changed, 36 insertions(+) create mode 100644 tests/fuzz/Makefile create mode 100644 tests/fuzz/README.md create mode 100644 tests/fuzz/fuzz.c create mode 120000 tests/fuzz/sha3.c create mode 120000 tests/fuzz/sha3.h (limited to 'tests/fuzz') diff --git a/tests/fuzz/Makefile b/tests/fuzz/Makefile new file mode 100644 index 0000000..9c305a8 --- /dev/null +++ b/tests/fuzz/Makefile @@ -0,0 +1,21 @@ +CFLAGS=-g -fsanitize=address,fuzzer -W -Wall -Wextra -Werror -pedantic -std=c11 +APP=./fuzz-shake128 +OBJS=sha3.o fuzz.o +CC=clang + +.PHONY=all clean fuzz + +all: $(APP) + +# build sample application +$(APP): $(OBJS) + $(CC) -o $(APP) $(CFLAGS) $(OBJS) + +%.o: %.c + $(CC) -c $(CFLAGS) $< + +fuzz: $(APP) + $(APP) + +clean: + $(RM) -f $(APP) $(OBJS) diff --git a/tests/fuzz/README.md b/tests/fuzz/README.md new file mode 100644 index 0000000..2acf59d --- /dev/null +++ b/tests/fuzz/README.md @@ -0,0 +1,6 @@ +# fuzz + +Initial fuzz testing based on [libFuzzer][]. + +[libfuzzer]: http://libfuzzer.info/ + "clang-based fuzzer." diff --git a/tests/fuzz/fuzz.c b/tests/fuzz/fuzz.c new file mode 100644 index 0000000..6045186 --- /dev/null +++ b/tests/fuzz/fuzz.c @@ -0,0 +1,7 @@ +#include "sha3.h" + +int LLVMFuzzerTestOneInput(const uint8_t *src, size_t len) { + uint8_t dst[128]; + shake128_xof_once(src, len, dst, sizeof(dst)); + return 0; +} diff --git a/tests/fuzz/sha3.c b/tests/fuzz/sha3.c new file mode 120000 index 0000000..4748193 --- /dev/null +++ b/tests/fuzz/sha3.c @@ -0,0 +1 @@ +../../sha3.c \ No newline at end of file diff --git a/tests/fuzz/sha3.h b/tests/fuzz/sha3.h new file mode 120000 index 0000000..b7c53d4 --- /dev/null +++ b/tests/fuzz/sha3.h @@ -0,0 +1 @@ +../../sha3.h \ No newline at end of file -- cgit v1.2.3