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