xref: /freebsd/crypto/openssh/regress/misc/fuzz-harness/Makefile (revision 657729a89dd578d8cfc70d6616f5c65a48a8b33a)
1# NB. libssh and libopenbsd-compat should be built with the same sanitizer opts.
2CC=clang-11
3CXX=clang++-11
4FUZZ_FLAGS=-fsanitize=address,fuzzer -fno-omit-frame-pointer
5FUZZ_LIBS=-lFuzzer
6
7CXXFLAGS=-O2 -g -Wall -Wextra -Wno-unused-parameter -I ../../.. $(FUZZ_FLAGS)
8CFLAGS=$(CXXFLAGS)
9LDFLAGS=-L ../../.. -L ../../../openbsd-compat -g $(FUZZ_FLAGS)
10LIBS=-lssh -lopenbsd-compat -lmd -lcrypto -lfido2 -lcbor $(FUZZ_LIBS)
11SK_NULL_OBJS=ssh-sk-null.o
12COMMON_DEPS=../../../libssh.a
13
14TARGETS=pubkey_fuzz sig_fuzz authopt_fuzz authkeys_fuzz sshsig_fuzz \
15	sshsigopt_fuzz privkey_fuzz kex_fuzz agent_fuzz
16
17all: $(TARGETS)
18
19.cc.o:
20	$(CXX) $(CXXFLAGS) -c $< -o $@
21
22pubkey_fuzz: pubkey_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
23	$(CXX) -o $@ pubkey_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
24
25sig_fuzz: sig_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
26	$(CXX) -o $@ sig_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
27
28authopt_fuzz: authopt_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
29	$(CXX) -o $@ authopt_fuzz.o $(SK_NULL_OBJS) ../../../auth-options.o $(LDFLAGS) $(LIBS)
30
31authkeys_fuzz: authkeys_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
32	$(CXX) -o $@ authkeys_fuzz.o $(SK_NULL_OBJS) ../../../auth-options.o ../../../auth2-pubkeyfile.o $(LDFLAGS) $(LIBS)
33
34sshsig_fuzz: sshsig_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
35	$(CXX) -o $@ sshsig_fuzz.o $(SK_NULL_OBJS) ../../../sshsig.o $(LDFLAGS) $(LIBS)
36
37sshsigopt_fuzz: sshsigopt_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
38	$(CXX) -o $@ sshsigopt_fuzz.o $(SK_NULL_OBJS) ../../../sshsig.o $(LDFLAGS) $(LIBS)
39
40privkey_fuzz: privkey_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
41	$(CXX) -o $@ privkey_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS)
42
43kex_fuzz: kex_fuzz.o $(SK_NULL_OBJS) $(COMMON_DEPS)
44	$(CXX) -o $@ kex_fuzz.o $(SK_NULL_OBJS) $(LDFLAGS) $(LIBS) -lz
45
46agent_fuzz: agent_fuzz.o agent_fuzz_helper.o sk-dummy.o ../../../ssh-sk.o $(COMMON_DEPS)
47	$(CXX) -o $@ agent_fuzz.o agent_fuzz_helper.o sk-dummy.o ../../../ssh-sk.o $(LDFLAGS) $(LIBS) -lz
48
49agent_fuzz_helper.o: agent_fuzz_helper.c ../../../ssh-agent.c
50
51sk-dummy.o: ../sk-dummy/sk-dummy.c
52	$(CC) $(CFLAGS) -c -o $@ ../sk-dummy/sk-dummy.c -DSK_DUMMY_INTEGRATE=1 $(LDFLAGS)
53
54clean:
55	-rm -f *.o $(TARGETS)
56