diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-03 21:29:10 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-04-03 21:38:01 +0200 |
commit | f06e75b32ab8b083550cff861997a93463c2b585 (patch) | |
tree | 0931a4929e43652862fe753b0723bb3ab7db0a33 | |
parent | Add gmp tests (diff) | |
download | curve25519-precomp-fuzzer-f06e75b32ab8b083550cff861997a93463c2b585.tar.xz curve25519-precomp-fuzzer-f06e75b32ab8b083550cff861997a93463c2b585.zip |
Support running on afl
-rw-r--r-- | gmp/Makefile | 8 | ||||
-rw-r--r-- | gmp/gmp_fp25519_a24.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_add.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_fred.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_inv.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_mul.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_mul2.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_red.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_red2.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_sqr.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_sqr2.c | 2 | ||||
-rw-r--r-- | gmp/gmp_fp25519_sub.c | 2 | ||||
-rwxr-xr-x | gmp/run-llvm.sh (renamed from gmp/run.sh) | 22 | ||||
-rw-r--r-- | gmp/shims/afl.c | 15 | ||||
-rw-r--r-- | gmp/shims/kernel.h (renamed from gmp/shim.h) | 0 |
15 files changed, 42 insertions, 25 deletions
diff --git a/gmp/Makefile b/gmp/Makefile index 4cc9d55..201597a 100644 --- a/gmp/Makefile +++ b/gmp/Makefile @@ -1,12 +1,14 @@ CFLAGS ?= -O3 -march=native -fomit-frame-pointer -TARGETS := $(basename $(wildcard *.c)) +TARGETS := $(foreach target,$(basename $(wildcard *.c)),$(target).llvm) $(foreach target,$(basename $(wildcard *.c)),$(target).afl) all: $(TARGETS) -%: %.c +%.llvm: %.c clang -o $@ $(CFLAGS) -I../bogus-include -fsanitize=fuzzer -lgmp $< +%.afl: %.c + afl-gcc -o $@ $(CFLAGS) -I../bogus-include -lgmp $< shims/afl.c clean: - rm -f $(basename $(TARGETS)) *.log + rm -rf $(TARGETS) *.logs .PHONY: clean all diff --git a/gmp/gmp_fp25519_a24.c b/gmp/gmp_fp25519_a24.c index 75e4d7d..6383226 100644 --- a/gmp/gmp_fp25519_a24.c +++ b/gmp/gmp_fp25519_a24.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_add.c b/gmp/gmp_fp25519_add.c index 7c2751c..078fe23 100644 --- a/gmp/gmp_fp25519_add.c +++ b/gmp/gmp_fp25519_add.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_fred.c b/gmp/gmp_fp25519_fred.c index cba671b..ecc9433 100644 --- a/gmp/gmp_fp25519_fred.c +++ b/gmp/gmp_fp25519_fred.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_inv.c b/gmp/gmp_fp25519_inv.c index bf7c2f5..59ba0bc 100644 --- a/gmp/gmp_fp25519_inv.c +++ b/gmp/gmp_fp25519_inv.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_mul.c b/gmp/gmp_fp25519_mul.c index ebdd5bc..5c7fd98 100644 --- a/gmp/gmp_fp25519_mul.c +++ b/gmp/gmp_fp25519_mul.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_mul2.c b/gmp/gmp_fp25519_mul2.c index 3fd0308..d1fc435 100644 --- a/gmp/gmp_fp25519_mul2.c +++ b/gmp/gmp_fp25519_mul2.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_red.c b/gmp/gmp_fp25519_red.c index 5f8d226..a77ab4b 100644 --- a/gmp/gmp_fp25519_red.c +++ b/gmp/gmp_fp25519_red.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_red2.c b/gmp/gmp_fp25519_red2.c index ed29a30..1770008 100644 --- a/gmp/gmp_fp25519_red2.c +++ b/gmp/gmp_fp25519_red2.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_sqr.c b/gmp/gmp_fp25519_sqr.c index 3f85c84..22b9788 100644 --- a/gmp/gmp_fp25519_sqr.c +++ b/gmp/gmp_fp25519_sqr.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_sqr2.c b/gmp/gmp_fp25519_sqr2.c index 132567a..0e89601 100644 --- a/gmp/gmp_fp25519_sqr2.c +++ b/gmp/gmp_fp25519_sqr2.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/gmp_fp25519_sub.c b/gmp/gmp_fp25519_sub.c index 962e541..aef90f9 100644 --- a/gmp/gmp_fp25519_sub.c +++ b/gmp/gmp_fp25519_sub.c @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> -#include "shim.h" +#include "shims/kernel.h" #include <gmp.h> #include <string.h> diff --git a/gmp/run.sh b/gmp/run-llvm.sh index c89d313..6d9ced7 100755 --- a/gmp/run.sh +++ b/gmp/run-llvm.sh @@ -1,13 +1,13 @@ #!/bin/bash -mkdir -p gmp_fp25519_fred.logs && cd gmp_fp25519_fred.logs; ../gmp_fp25519_fred -max_len=32 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_sqr2.logs && cd gmp_fp25519_sqr2.logs; ../gmp_fp25519_sqr2 -max_len=64 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_inv.logs && cd gmp_fp25519_inv.logs; ../gmp_fp25519_inv -max_len=32 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_red2.logs && cd gmp_fp25519_red2.logs; ../gmp_fp25519_red2 -max_len=128 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_mul2.logs && cd gmp_fp25519_mul2.logs; ../gmp_fp25519_mul2 -max_len=128 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_sqr.logs && cd gmp_fp25519_sqr.logs; ../gmp_fp25519_sqr -max_len=32 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_red.logs && cd gmp_fp25519_red.logs; ../gmp_fp25519_red -max_len=64 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_add.logs && cd gmp_fp25519_add.logs; ../gmp_fp25519_add -max_len=64 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_a24.logs && cd gmp_fp25519_a24.logs; ../gmp_fp25519_a24 -max_len=32 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_sub.logs && cd gmp_fp25519_sub.logs; ../gmp_fp25519_sub -max_len=64 -workers=5 -jobs=5 & cd .. -mkdir -p gmp_fp25519_mul.logs && cd gmp_fp25519_mul.logs; ../gmp_fp25519_mul -max_len=64 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_fred.logs && cd gmp_fp25519_fred.logs; ../gmp_fp25519_fred.llvm -max_len=32 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_sqr2.logs && cd gmp_fp25519_sqr2.logs; ../gmp_fp25519_sqr2.llvm -max_len=64 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_inv.logs && cd gmp_fp25519_inv.logs; ../gmp_fp25519_inv.llvm -max_len=32 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_red2.logs && cd gmp_fp25519_red2.logs; ../gmp_fp25519_red2.llvm -max_len=128 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_mul2.logs && cd gmp_fp25519_mul2.logs; ../gmp_fp25519_mul2.llvm -max_len=128 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_sqr.logs && cd gmp_fp25519_sqr.logs; ../gmp_fp25519_sqr.llvm -max_len=32 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_red.logs && cd gmp_fp25519_red.logs; ../gmp_fp25519_red.llvm -max_len=64 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_add.logs && cd gmp_fp25519_add.logs; ../gmp_fp25519_add.llvm -max_len=64 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_a24.logs && cd gmp_fp25519_a24.logs; ../gmp_fp25519_a24.llvm -max_len=32 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_sub.logs && cd gmp_fp25519_sub.logs; ../gmp_fp25519_sub.llvm -max_len=64 -workers=5 -jobs=5 & cd .. +mkdir -p gmp_fp25519_mul.logs && cd gmp_fp25519_mul.logs; ../gmp_fp25519_mul.llvm -max_len=64 -workers=5 -jobs=5 & cd .. wait diff --git a/gmp/shims/afl.c b/gmp/shims/afl.c new file mode 100644 index 0000000..1917bd5 --- /dev/null +++ b/gmp/shims/afl.c @@ -0,0 +1,15 @@ +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> + +extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +int main(int argc, char *argv[]) +{ + uint8_t data[1024]; + ssize_t size; + + if ((size = read(STDIN_FILENO, data, sizeof(data))) < 0) + return EXIT_FAILURE; + return LLVMFuzzerTestOneInput(data, size); +} diff --git a/gmp/shim.h b/gmp/shims/kernel.h index 9ce3775..9ce3775 100644 --- a/gmp/shim.h +++ b/gmp/shims/kernel.h |