1# $OpenBSD: Makefile,v 1.7 2023/10/30 17:15:21 tb Exp $
2
3LIBRARIES =		libressl
4.if exists(/usr/local/bin/eopenssl11)
5LIBRARIES +=		openssl11
6.endif
7.if exists(/usr/local/bin/eopenssl30)
8LIBRARIES +=		openssl30
9.endif
10.if exists(/usr/local/bin/eopenssl31)
11LIBRARIES +=		openssl31
12.endif
13
14# run netcat server and connect with test client
15
16.for clib in ${LIBRARIES}
17
18REGRESS_TARGETS +=	run-netcat-client-${clib}-server-nc
19REGRESS_TARGETS +=	run-protocol-client-${clib}
20
21run-netcat-client-${clib}-server-nc: ../${clib}/client 127.0.0.1.crt
22	echo "greeting" | \
23	    nc >${@:S/^run/server/}.out \
24	    -l -c -C 127.0.0.1.crt -K 127.0.0.1.key \
25	    127.0.0.1 0 & \
26	    for i in `jot 1000`; do fstat -p $$! >netcat.fstat; \
27	    grep -q ' stream tcp .*:[1-9][0-9]*$$' netcat.fstat && \
28	    exit 0; done; exit 1
29	LD_LIBRARY_PATH=/usr/local/lib/e${clib} \
30	    ../${clib}/client >${@:S/^run/client/}.out \
31	    `sed -n 's/.* stream tcp .*:/127.0.0.1 /p' netcat.fstat`
32	# check that the client run successfully to the end
33	grep -q '^success$$' ${@:S/^run/client/}.out
34	# client must have read server greeting
35	grep -q '^<<< greeting$$' ${@:S/^run/client/}.out
36	# netstat server must have read client hello
37	grep -q '^hello$$' ${@:S/^run/server/}.out
38
39.endfor
40
41# run test server and connect with netcat client
42
43.for slib in ${LIBRARIES}
44
45REGRESS_TARGETS +=	run-netcat-client-nc-server-${slib}
46
47run-netcat-client-nc-server-${slib}: ../${slib}/server 127.0.0.1.crt
48	LD_LIBRARY_PATH=/usr/local/lib/e${slib} \
49	    ../${slib}/server >${@:S/^run/server/}.out \
50	    127.0.0.1 0
51	echo "hello" | \
52	    nc >${@:S/^run/client/}.out \
53	    -c -R 127.0.0.1.crt \
54	    `sed -n 's/listen sock: //p' ${@:S/^run/server/}.out`
55	# check that the server child run successfully to the end
56	grep -q '^success$$' ${@:S/^run/server/}.out || \
57	    { sleep 1; grep -q '^success$$' ${@:S/^run/server/}.out; }
58	# server must have read client hello
59	grep -q '^<<< hello$$' ${@:S/^run/server/}.out
60	# client must have read server greeting
61	grep -q '^greeting$$' ${@:S/^run/client/}.out
62
63.endfor
64
65# check the TLS protocol version in client and server logs
66
67.for clib in ${LIBRARIES}
68
69REGRESS_TARGETS +=	run-protocol-client-${clib}
70
71run-protocol-client-${clib}: client-netcat-client-${clib}-server-nc.out
72	# check that LibTLS protocol version is TLS 1.2 or TLS 1.3
73	grep 'Protocol *: TLSv1.[23]' client-netcat-client-${clib}-server-nc.out
74
75.endfor
76
77.for slib in ${LIBRARIES}
78
79REGRESS_TARGETS +=	run-protocol-server-${slib}
80
81run-protocol-server-${slib}: server-netcat-client-nc-server-${slib}.out
82	# check that LibTLS protocol version is TLS 1.2 or TLS 1.3
83	grep 'Protocol *: TLSv1.[23]' server-netcat-client-nc-server-${slib}.out
84
85.endfor
86
87.include <bsd.regress.mk>
88