1# $OpenBSD: Makefile,v 1.7 2023/10/30 17:15:21 tb Exp $
2
3.include <bsd.own.mk>
4
5.if ! exists(/usr/local/bin/botan)
6regress:
7	# install botan2 from ports for interop tests
8	@echo 'Run "pkg_add botan2" to run tests against Botan 2'
9	@echo SKIPPED
10.elif (${COMPILER_VERSION:L} != "clang" && ! exists(/usr/local/bin/eg++))
11regress:
12	# on gcc-archs install g++ from ports for botan2 interop tests
13	@echo 'Run "pkg_add g++" to run tests against Botan 2 on GCC architectures'
14	@echo SKIPPED
15.else
16
17# C++11
18.if ${COMPILER_VERSION:L} != "clang" && ${CXX} == "c++"
19CXX = /usr/local/bin/eg++
20.endif
21
22LIBRARIES =		libressl
23.if exists(/usr/local/bin/eopenssl11)
24LIBRARIES +=		openssl11
25.endif
26.if exists(/usr/local/bin/eopenssl30)
27LIBRARIES +=		openssl30
28.endif
29.if exists(/usr/local/bin/eopenssl31)
30LIBRARIES +=		openssl31
31.endif
32
33PROGS =		client
34SRCS_client =	client.cpp
35CXXFLAGS =	-I/usr/local/include/botan-2 -Wall
36LDFLAGS =	-L/usr/local/lib
37LDADD =		-lbotan-2
38DPADD =		/usr/local/lib/libbotan-2.a
39
40.for lib in ${LIBRARIES}
41
42REGRESS_TARGETS += run-client-botan-server-${lib}
43
44run-client-botan-server-${lib}: client server.crt
45	LD_LIBRARY_PATH=/usr/local/lib/e${lib} \
46	    ../${lib}/server >server-${lib}.out \
47	    -c server.crt -k server.key \
48	    127.0.0.1 0
49	./client >client-botan.out \
50	    -C ca.crt \
51	    127.0.0.1 \
52	    `sed -n 's/listen sock: 127.0.0.1 //p' server-${lib}.out`
53	# check that the server child run successfully to the end
54	grep -q '^success$$' server-${lib}.out || \
55	    { sleep 1; grep -q '^success$$' server-${lib}.out; }
56	# server must have read client hello
57	grep -q '^<<< hello$$' server-${lib}.out
58	# check that the client run successfully to the end
59	grep -q '^success$$' client-botan.out
60	# client must have read server greeting
61	grep -q '^<<< greeting$$' client-botan.out
62	# currently botan supports TLS 1.2, adapt later
63	grep -q ' Protocol *: TLSv1.2$$' server-${lib}.out
64
65.endfor
66
67server.key ca.key:
68	/usr/local/bin/botan keygen >$@.tmp
69	mv $@.tmp $@
70
71ca.crt: ${@:R}.key
72	/usr/local/bin/botan gen_self_signed ${@:R}.key ${@:R} >$@.tmp \
73	    --organization=tls-regress --ca
74	mv $@.tmp $@
75
76server.req: ${@:R}.key
77	/usr/local/bin/botan gen_pkcs10 ${@:R}.key localhost >$@.tmp \
78	    --organization=tls-regress --dns=127.0.0.1
79	mv $@.tmp $@
80
81server.crt: ca.crt ${@:R}.req
82	/usr/local/bin/botan sign_cert ca.crt ca.key ${@:R}.req >$@.tmp
83	mv $@.tmp $@
84
85.endif # exists(/usr/local/bin/botan)
86
87.include <bsd.regress.mk>
88