xref: /freebsd/crypto/openssh/regress/putty-ciphers.sh (revision a91a246563dffa876a52f53a98de4af9fa364c52)
1*a91a2465SEd Maste#	$OpenBSD: putty-ciphers.sh,v 1.13 2024/02/09 08:56:59 dtucker Exp $
2ce3adf43SDag-Erling Smørgrav#	Placed in the Public Domain.
3ce3adf43SDag-Erling Smørgrav
4ce3adf43SDag-Erling Smørgravtid="putty ciphers"
5ce3adf43SDag-Erling Smørgrav
6*a91a2465SEd Masteputtysetup
7e9e8876aSEd Maste
8*a91a2465SEd Mastecp ${OBJ}/sshd_proxy ${OBJ}/sshd_proxy_bak
9ce3adf43SDag-Erling Smørgrav
10*a91a2465SEd Maste# Since there doesn't seem to be a way to set MACs on the PuTTY client side,
11*a91a2465SEd Maste# we force each in turn on the server side, omitting the ones PuTTY doesn't
12*a91a2465SEd Maste# support.  Grepping the binary is pretty janky, but AFAIK there's no way to
13*a91a2465SEd Maste# query for supported algos.
14*a91a2465SEd Mastemacs=""
15*a91a2465SEd Mastefor m in `${SSH} -Q MACs`; do
16*a91a2465SEd Maste	if strings "${PLINK}" | grep -E "^${m}$" >/dev/null; then
17*a91a2465SEd Maste		macs="${macs} ${m}"
18*a91a2465SEd Maste	else
19*a91a2465SEd Maste		trace "omitting unsupported MAC ${m}"
20*a91a2465SEd Maste	fi
21*a91a2465SEd Mastedone
22*a91a2465SEd Maste
23*a91a2465SEd Masteciphers=""
24*a91a2465SEd Mastefor c in `${SSH} -Q Ciphers`; do
25*a91a2465SEd Maste	if strings "${PLINK}" | grep -E "^${c}$" >/dev/null; then
26*a91a2465SEd Maste		ciphers="${ciphers} ${c}"
27*a91a2465SEd Maste	else
28*a91a2465SEd Maste		trace "omitting unsupported cipher ${c}"
29*a91a2465SEd Maste	fi
30*a91a2465SEd Mastedone
31*a91a2465SEd Maste
32*a91a2465SEd Mastefor c in default $ciphers; do
33*a91a2465SEd Maste    for m in default ${macs}; do
34*a91a2465SEd Maste	verbose "$tid: cipher $c mac $m"
35ce3adf43SDag-Erling Smørgrav	cp ${OBJ}/.putty/sessions/localhost_proxy \
36ce3adf43SDag-Erling Smørgrav	    ${OBJ}/.putty/sessions/cipher_$c
37*a91a2465SEd Maste	if [ "${c}" != "default" ]; then
38ce3adf43SDag-Erling Smørgrav		echo "Cipher=$c" >> ${OBJ}/.putty/sessions/cipher_$c
39*a91a2465SEd Maste	fi
40*a91a2465SEd Maste
41*a91a2465SEd Maste	cp ${OBJ}/sshd_proxy_bak ${OBJ}/sshd_proxy
42*a91a2465SEd Maste	if [ "${m}" != "default" ]; then
43*a91a2465SEd Maste		echo "MACs $m" >> ${OBJ}/sshd_proxy
44*a91a2465SEd Maste	fi
45ce3adf43SDag-Erling Smørgrav
46ce3adf43SDag-Erling Smørgrav	rm -f ${COPY}
4747dd1d1bSDag-Erling Smørgrav	env HOME=$PWD ${PLINK} -load cipher_$c -batch -i ${OBJ}/putty.rsa2 \
48ca86bcf2SDag-Erling Smørgrav	    cat ${DATA} > ${COPY}
49ce3adf43SDag-Erling Smørgrav	if [ $? -ne 0 ]; then
50ce3adf43SDag-Erling Smørgrav		fail "ssh cat $DATA failed"
51ce3adf43SDag-Erling Smørgrav	fi
52ce3adf43SDag-Erling Smørgrav	cmp ${DATA} ${COPY}		|| fail "corrupted copy"
53ce3adf43SDag-Erling Smørgrav    done
54*a91a2465SEd Mastedone
55ce3adf43SDag-Erling Smørgravrm -f ${COPY}
56