summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2019-09-05 11:09:28 +1000
committerDamien Miller <djm@mindrot.org>2019-09-05 14:26:39 +1000
commitf4846dfc6a79f84bbc6356ae3184f142bacedc24 (patch)
treeda1324ec5f17b881d6fec177623aeccf90ea7820 /regress
parentb08a6bc1cc7750c6f8a425d1cdbd86552fffc637 (diff)
Fuzzer harness for sshsig
Diffstat (limited to 'regress')
-rw-r--r--regress/misc/fuzz-harness/Makefile5
-rw-r--r--regress/misc/fuzz-harness/sshsig_fuzz.cc35
2 files changed, 39 insertions, 1 deletions
diff --git a/regress/misc/fuzz-harness/Makefile b/regress/misc/fuzz-harness/Makefile
index a2aa4441f..6ab7d7217 100644
--- a/regress/misc/fuzz-harness/Makefile
+++ b/regress/misc/fuzz-harness/Makefile
@@ -7,7 +7,7 @@ CXXFLAGS=-O2 -g -Wall -Wextra -I ../../.. $(FUZZ_FLAGS)
7LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS) 7LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
8LIBS=-lssh -lopenbsd-compat -lcrypto $(FUZZ_LIBS) 8LIBS=-lssh -lopenbsd-compat -lcrypto $(FUZZ_LIBS)
9 9
10all: pubkey_fuzz sig_fuzz authopt_fuzz 10all: pubkey_fuzz sig_fuzz authopt_fuzz sshsig_fuzz
11 11
12.cc.o: 12.cc.o:
13 $(CXX) $(CXXFLAGS) -c $< -o $@ 13 $(CXX) $(CXXFLAGS) -c $< -o $@
@@ -21,5 +21,8 @@ sig_fuzz: sig_fuzz.o
21authopt_fuzz: authopt_fuzz.o 21authopt_fuzz: authopt_fuzz.o
22 $(CXX) -o $@ authopt_fuzz.o ../../../auth-options.o $(LDFLAGS) $(LIBS) 22 $(CXX) -o $@ authopt_fuzz.o ../../../auth-options.o $(LDFLAGS) $(LIBS)
23 23
24sshsig_fuzz: sshsig_fuzz.o
25 $(CXX) -o $@ sshsig_fuzz.o ../../../sshsig.o $(LDFLAGS) $(LIBS)
26
24clean: 27clean:
25 -rm -f *.o pubkey_fuzz sig_fuzz authopt_fuzz 28 -rm -f *.o pubkey_fuzz sig_fuzz authopt_fuzz
diff --git a/regress/misc/fuzz-harness/sshsig_fuzz.cc b/regress/misc/fuzz-harness/sshsig_fuzz.cc
new file mode 100644
index 000000000..fe09ccb87
--- /dev/null
+++ b/regress/misc/fuzz-harness/sshsig_fuzz.cc
@@ -0,0 +1,35 @@
1// cc_fuzz_target test for sshsig verification.
2
3#include <stddef.h>
4#include <stdio.h>
5#include <stdint.h>
6#include <stdlib.h>
7#include <string.h>
8
9extern "C" {
10
11#include "includes.h"
12#include "sshkey.h"
13#include "ssherr.h"
14#include "sshbuf.h"
15#include "sshsig.h"
16#include "log.h"
17
18int LLVMFuzzerTestOneInput(const uint8_t* sig, size_t slen)
19{
20 static const char *data = "If everyone started announcing his nose had "
21 "run away, I don’t know how it would all end";
22 struct sshbuf *signature = sshbuf_from(sig, slen);
23 struct sshbuf *message = sshbuf_from(data, strlen(data));
24 struct sshkey *k = NULL;
25 extern char *__progname;
26
27 log_init(__progname, SYSLOG_LEVEL_QUIET, SYSLOG_FACILITY_USER, 1);
28 sshsig_verifyb(signature, message, "castle", &k);
29 sshkey_free(k);
30 sshbuf_free(signature);
31 sshbuf_free(message);
32 return 0;
33}
34
35} // extern