xref: /freebsd/crypto/openssh/regress/ssh-com-keygen.sh (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1#	$OpenBSD: ssh-com-keygen.sh,v 1.4 2004/02/24 17:06:52 markus Exp $
2#	Placed in the Public Domain.
3
4tid="ssh.com key import"
5
6#TEST_COMBASE=/path/to/ssh/com/binaries
7if [ "X${TEST_COMBASE}" = "X" ]; then
8	fatal '$TEST_COMBASE is not set'
9fi
10
11VERSIONS="
12	2.0.10
13	2.0.12
14	2.0.13
15	2.1.0
16	2.2.0
17	2.3.0
18	2.3.1
19	2.4.0
20	3.0.0
21	3.1.0
22	3.2.0
23	3.2.2
24	3.2.3
25	3.2.5
26	3.2.9
27	3.2.9.1
28	3.3.0"
29
30COMPRV=${OBJ}/comkey
31COMPUB=${COMPRV}.pub
32OPENSSHPRV=${OBJ}/opensshkey
33OPENSSHPUB=${OPENSSHPRV}.pub
34
35# go for it
36for v in ${VERSIONS}; do
37	keygen=${TEST_COMBASE}/${v}/ssh-keygen2
38	if [ ! -x ${keygen} ]; then
39		continue
40	fi
41	types="dss"
42        case $v in
43        2.3.1|3.*)
44                types="$types rsa"
45                ;;
46        esac
47	for t in $types; do
48		verbose "ssh-keygen $v/$t"
49		rm -f $COMPRV $COMPUB $OPENSSHPRV $OPENSSHPUB
50		${keygen} -q -P -t $t ${COMPRV} > /dev/null 2>&1
51		if [ $? -ne 0 ]; then
52			fail "${keygen} -t $t failed"
53			continue
54		fi
55		${SSHKEYGEN} -if ${COMPUB} > ${OPENSSHPUB}
56		if [ $? -ne 0 ]; then
57			fail "import public key ($v/$t) failed"
58			continue
59		fi
60		${SSHKEYGEN} -if ${COMPRV} > ${OPENSSHPRV}
61		if [ $? -ne 0 ]; then
62			fail "import private key ($v/$t) failed"
63			continue
64		fi
65		chmod 600 ${OPENSSHPRV}
66		${SSHKEYGEN} -yf ${OPENSSHPRV} |\
67			diff - ${OPENSSHPUB}
68		if [ $? -ne 0 ]; then
69			fail "public keys ($v/$t) differ"
70		fi
71	done
72done
73
74rm -f $COMPRV $COMPUB $OPENSSHPRV $OPENSSHPUB
75