1#	$OpenBSD: putty-kex.sh,v 1.11 2024/02/09 08:56:59 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="putty KEX"
5
6puttysetup
7
8cp ${OBJ}/sshd_proxy ${OBJ}/sshd_proxy_bak
9
10# Enable group1, which PuTTY now disables by default
11echo "KEX=dh-group1-sha1" >>${OBJ}/.putty/sessions/localhost_proxy
12
13# Grepping algos out of the binary is pretty janky, but AFAIK there's no way
14# to query supported algos.
15kex=""
16for k in `$SSH -Q kex`; do
17	if strings "${PLINK}" | grep -E "^${k}$" >/dev/null; then
18		kex="${kex} ${k}"
19	else
20		trace "omitting unsupported KEX ${k}"
21	fi
22done
23
24for k in ${kex}; do
25	verbose "$tid: kex $k"
26	cp ${OBJ}/sshd_proxy_bak ${OBJ}/sshd_proxy
27	echo "KexAlgorithms ${k}" >>${OBJ}/sshd_proxy
28
29	env HOME=$PWD ${PLINK} -v -load localhost_proxy -batch -i ${OBJ}/putty.rsa2 true \
30	    2>${OBJ}/log/putty-kex-$k.log
31	if [ $? -ne 0 ]; then
32		fail "KEX $k failed"
33	fi
34	kexmsg=`grep -E '^Doing.* key exchange' ${OBJ}/log/putty-kex-$k.log`
35	trace putty: ${kexmsg}
36done
37