summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-13 07:49:49 +0000
committerDamien Miller <djm@mindrot.org>2015-01-15 21:39:15 +1100
commit0920553d0aee117a596b03ed5b49b280d34a32c5 (patch)
treec3095b49a5b99b93bb76c7fd24c1c36e917b3716
parent27ca1a5c0095eda151934bca39a77e391f875d17 (diff)
upstream commit
regress test for PubkeyAcceptedKeyTypes; ok markus@
-rw-r--r--regress/Makefile7
-rw-r--r--regress/limit-keytype.sh80
2 files changed, 85 insertions, 2 deletions
diff --git a/regress/Makefile b/regress/Makefile
index dd3b79506..2e068e94a 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.73 2015/01/12 20:13:27 markus Exp $ 1# $OpenBSD: Makefile,v 1.74 2015/01/13 07:49:49 djm Exp $
2 2
3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec 3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec
4tests: $(REGRESS_TARGETS) 4tests: $(REGRESS_TARGETS)
@@ -65,7 +65,10 @@ LTESTS= connect \
65 forward-control \ 65 forward-control \
66 integrity \ 66 integrity \
67 krl \ 67 krl \
68 multipubkey 68 multipubkey \
69 limit-keytype
70
71
69# dhgex \ 72# dhgex \
70 73
71INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers 74INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers
diff --git a/regress/limit-keytype.sh b/regress/limit-keytype.sh
new file mode 100644
index 000000000..2de037bd1
--- /dev/null
+++ b/regress/limit-keytype.sh
@@ -0,0 +1,80 @@
1# $OpenBSD: limit-keytype.sh,v 1.1 2015/01/13 07:49:49 djm Exp $
2# Placed in the Public Domain.
3
4tid="restrict pubkey type"
5
6rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/user_key*
7rm -f $OBJ/authorized_principals_$USER $OBJ/cert_user_key*
8
9mv $OBJ/sshd_proxy $OBJ/sshd_proxy.orig
10mv $OBJ/ssh_proxy $OBJ/ssh_proxy.orig
11
12# Create a CA key
13${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_ca_key ||\
14 fatal "ssh-keygen failed"
15
16# Make some keys and a certificate.
17${SSHKEYGEN} -q -N '' -t ed25519 -f $OBJ/user_key1 || \
18 fatal "ssh-keygen failed"
19${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_key2 || \
20 fatal "ssh-keygen failed"
21${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_key3 || \
22 fatal "ssh-keygen failed"
23${SSHKEYGEN} -q -s $OBJ/user_ca_key -I "regress user key for $USER" \
24 -z $$ -n ${USER},mekmitasdigoat $OBJ/user_key3 ||
25 fatal "couldn't sign user_key1"
26# Copy the private key alongside the cert to allow better control of when
27# it is offered.
28mv $OBJ/user_key3-cert.pub $OBJ/cert_user_key3.pub
29cp -p $OBJ/user_key3 $OBJ/cert_user_key3
30
31grep -v IdentityFile $OBJ/ssh_proxy.orig > $OBJ/ssh_proxy
32
33opts="-oProtocol=2 -F $OBJ/ssh_proxy -oIdentitiesOnly=yes"
34fullopts="$opts -i $OBJ/cert_user_key3 -i $OBJ/user_key1 -i $OBJ/user_key2"
35
36echo mekmitasdigoat > $OBJ/authorized_principals_$USER
37cat $OBJ/user_key1.pub > $OBJ/authorized_keys_$USER
38cat $OBJ/user_key2.pub >> $OBJ/authorized_keys_$USER
39
40prepare_config() {
41 (
42 grep -v "Protocol" $OBJ/sshd_proxy.orig
43 echo "Protocol 2"
44 echo "AuthenticationMethods publickey"
45 echo "TrustedUserCAKeys $OBJ/user_ca_key.pub"
46 echo "AuthorizedPrincipalsFile $OBJ/authorized_principals_%u"
47 for x in "$@" ; do
48 echo "$x"
49 done
50 ) > $OBJ/sshd_proxy
51}
52
53prepare_config
54
55# Check we can log in with all key types.
56${SSH} $opts -i $OBJ/cert_user_key3 proxy true || fatal "cert failed"
57${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
58${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed"
59
60# Allow plain Ed25519 and RSA. The certificate should fail.
61verbose "privsep=$privsep allow rsa,ed25519"
62prepare_config "PubkeyAcceptedKeyTypes ssh-rsa,ssh-ed25519"
63${SSH} $opts -i $OBJ/cert_user_key3 proxy true && fatal "cert succeeded"
64${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
65${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed"
66
67# Allow Ed25519 only.
68verbose "privsep=$privsep allow ed25519"
69prepare_config "PubkeyAcceptedKeyTypes ssh-ed25519"
70${SSH} $opts -i $OBJ/cert_user_key3 proxy true && fatal "cert succeeded"
71${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
72${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded"
73
74# Allow all certs. Plain keys should fail.
75verbose "privsep=$privsep allow cert only"
76prepare_config "PubkeyAcceptedKeyTypes ssh-*-cert-v01@openssh.com"
77${SSH} $opts -i $OBJ/cert_user_key3 proxy true || fatal "cert failed"
78${SSH} $opts -i $OBJ/user_key1 proxy true && fatal "key1 succeeded"
79${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded"
80