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