]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: New style fuzzing tool for X.509 certificate parsing
authorJouni Malinen <j@w1.fi>
Sun, 2 Jun 2019 10:17:31 +0000 (13:17 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 2 Jun 2019 10:17:31 +0000 (13:17 +0300)
This is a newer version of tests/test-x509 tool.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/fuzzing/x509/Makefile [new file with mode: 0644]
tests/fuzzing/x509/corpus/ca.der [new file with mode: 0644]
tests/fuzzing/x509/x509.c [new file with mode: 0644]

diff --git a/tests/fuzzing/x509/Makefile b/tests/fuzzing/x509/Makefile
new file mode 100644 (file)
index 0000000..d7f751a
--- /dev/null
@@ -0,0 +1,20 @@
+all: x509
+include ../rules.include
+
+LIBS += $(SRC)/common/libcommon.a
+LIBS += $(SRC)/crypto/libcrypto.a
+LIBS += $(SRC)/tls/libtls.a
+LIBS += $(SRC)/utils/libutils.a
+
+ELIBS += $(SRC)/crypto/libcrypto.a
+ELIBS += $(SRC)/tls/libtls.a
+
+x509: x509.o $(OBJS) $(LIBS)
+       $(LDO) $(LDFLAGS) -o $@ $^ $(LIBS) $(ELIBS)
+
+clean:
+       $(MAKE) -C $(SRC) clean
+       $(MAKE) -C $(WPAS_SRC) clean
+       rm -f x509 *~ *.o *.d ../*~ ../*.o ../*.d
+
+-include $(OBJS:%.o=%.d)
diff --git a/tests/fuzzing/x509/corpus/ca.der b/tests/fuzzing/x509/corpus/ca.der
new file mode 100644 (file)
index 0000000..09d5fa0
Binary files /dev/null and b/tests/fuzzing/x509/corpus/ca.der differ
diff --git a/tests/fuzzing/x509/x509.c b/tests/fuzzing/x509/x509.c
new file mode 100644 (file)
index 0000000..2969fea
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Testing tool for X.509v3 routines
+ * Copyright (c) 2006-2019, Jouni Malinen <j@w1.fi>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "tls/x509v3.h"
+#include "../fuzzer-common.h"
+
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+       struct x509_certificate *cert;
+
+       wpa_fuzzer_set_debug_level();
+
+       cert = x509_certificate_parse(data, size);
+       x509_certificate_free(cert);
+       return 0;
+}