aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2023-09-17 03:31:23 -0400
committerPaul Duncan <pabs@pablotron.org>2023-09-17 03:31:23 -0400
commit75b6d96e139c65ba457120d04767a3fc1b948372 (patch)
tree3b296da56495cad9bfe20f58f9293185200b8014 /tests/fuzz
parent9dc538b3230c17671da35c8346a1f471aa6118f4 (diff)
downloadsha3-75b6d96e139c65ba457120d04767a3fc1b948372.tar.bz2
sha3-75b6d96e139c65ba457120d04767a3fc1b948372.zip
add tests/fuzz
Diffstat (limited to 'tests/fuzz')
-rw-r--r--tests/fuzz/Makefile21
-rw-r--r--tests/fuzz/README.md6
-rw-r--r--tests/fuzz/fuzz.c7
l---------tests/fuzz/sha3.c1
l---------tests/fuzz/sha3.h1
5 files changed, 36 insertions, 0 deletions
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