diff options
Diffstat (limited to 'regress/krl.sh')
-rw-r--r-- | regress/krl.sh | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/regress/krl.sh b/regress/krl.sh index 287384b4a..1077358ff 100644 --- a/regress/krl.sh +++ b/regress/krl.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: krl.sh,v 1.3 2014/06/24 01:04:43 djm Exp $ | 1 | # $OpenBSD: krl.sh,v 1.6 2015/01/30 01:11:39 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="key revocation lists" | 4 | tid="key revocation lists" |
@@ -17,6 +17,8 @@ rm -f $OBJ/revoked-* $OBJ/krl-* | |||
17 | # Generate a CA key | 17 | # Generate a CA key |
18 | $SSHKEYGEN -t $ECDSA -f $OBJ/revoked-ca -C "" -N "" > /dev/null || | 18 | $SSHKEYGEN -t $ECDSA -f $OBJ/revoked-ca -C "" -N "" > /dev/null || |
19 | fatal "$SSHKEYGEN CA failed" | 19 | fatal "$SSHKEYGEN CA failed" |
20 | $SSHKEYGEN -t ed25519 -f $OBJ/revoked-ca2 -C "" -N "" > /dev/null || | ||
21 | fatal "$SSHKEYGEN CA2 failed" | ||
20 | 22 | ||
21 | # A specification that revokes some certificates by serial numbers | 23 | # A specification that revokes some certificates by serial numbers |
22 | # The serial pattern is chosen to ensure the KRL includes list, range and | 24 | # The serial pattern is chosen to ensure the KRL includes list, range and |
@@ -45,6 +47,7 @@ EOF | |||
45 | # A specification that revokes some certificated by key ID. | 47 | # A specification that revokes some certificated by key ID. |
46 | touch $OBJ/revoked-keyid | 48 | touch $OBJ/revoked-keyid |
47 | for n in 1 2 3 4 10 15 30 50 `jot 500 300` 999 1000 1001 1002; do | 49 | for n in 1 2 3 4 10 15 30 50 `jot 500 300` 999 1000 1001 1002; do |
50 | test "x$n" = "x499" && continue | ||
48 | # Fill in by-ID revocation spec. | 51 | # Fill in by-ID revocation spec. |
49 | echo "id: revoked $n" >> $OBJ/revoked-keyid | 52 | echo "id: revoked $n" >> $OBJ/revoked-keyid |
50 | done | 53 | done |
@@ -56,7 +59,7 @@ keygen() { | |||
56 | keytype=$ECDSA | 59 | keytype=$ECDSA |
57 | case $N in | 60 | case $N in |
58 | 2 | 10 | 510 | 1001) keytype=rsa;; | 61 | 2 | 10 | 510 | 1001) keytype=rsa;; |
59 | 4 | 30 | 520 | 1002) keytype=dsa;; | 62 | 4 | 30 | 520 | 1002) keytype=ed25519;; |
60 | esac | 63 | esac |
61 | $SSHKEYGEN -t $keytype -f $f -C "" -N "" > /dev/null \ | 64 | $SSHKEYGEN -t $keytype -f $f -C "" -N "" > /dev/null \ |
62 | || fatal "$SSHKEYGEN failed" | 65 | || fatal "$SSHKEYGEN failed" |
@@ -71,37 +74,48 @@ verbose "$tid: generating test keys" | |||
71 | REVOKED_SERIALS="1 4 10 50 500 510 520 799 999" | 74 | REVOKED_SERIALS="1 4 10 50 500 510 520 799 999" |
72 | for n in $REVOKED_SERIALS ; do | 75 | for n in $REVOKED_SERIALS ; do |
73 | f=`keygen $n` | 76 | f=`keygen $n` |
74 | REVOKED_KEYS="$REVOKED_KEYS ${f}.pub" | 77 | RKEYS="$RKEYS ${f}.pub" |
75 | REVOKED_CERTS="$REVOKED_CERTS ${f}-cert.pub" | 78 | RCERTS="$RCERTS ${f}-cert.pub" |
76 | done | 79 | done |
77 | NOTREVOKED_SERIALS="5 9 14 16 29 30 49 51 499 800 1000 1001" | 80 | UNREVOKED_SERIALS="5 9 14 16 29 49 51 499 800 1010 1011" |
78 | NOTREVOKED="" | 81 | UNREVOKED="" |
79 | for n in $NOTREVOKED_SERIALS ; do | 82 | for n in $UNREVOKED_SERIALS ; do |
80 | NOTREVOKED_KEYS="$NOTREVOKED_KEYS ${f}.pub" | 83 | f=`keygen $n` |
81 | NOTREVOKED_CERTS="$NOTREVOKED_CERTS ${f}-cert.pub" | 84 | UKEYS="$UKEYS ${f}.pub" |
85 | UCERTS="$UCERTS ${f}-cert.pub" | ||
82 | done | 86 | done |
83 | 87 | ||
84 | genkrls() { | 88 | genkrls() { |
85 | OPTS=$1 | 89 | OPTS=$1 |
86 | $SSHKEYGEN $OPTS -kf $OBJ/krl-empty - </dev/null \ | 90 | $SSHKEYGEN $OPTS -kf $OBJ/krl-empty - </dev/null \ |
87 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 91 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
88 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keys $REVOKED_KEYS \ | 92 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keys $RKEYS \ |
89 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 93 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
90 | $SSHKEYGEN $OPTS -kf $OBJ/krl-cert $REVOKED_CERTS \ | 94 | $SSHKEYGEN $OPTS -kf $OBJ/krl-cert $RCERTS \ |
91 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 95 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
92 | $SSHKEYGEN $OPTS -kf $OBJ/krl-all $REVOKED_KEYS $REVOKED_CERTS \ | 96 | $SSHKEYGEN $OPTS -kf $OBJ/krl-all $RKEYS $RCERTS \ |
93 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 97 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
94 | $SSHKEYGEN $OPTS -kf $OBJ/krl-ca $OBJ/revoked-ca.pub \ | 98 | $SSHKEYGEN $OPTS -kf $OBJ/krl-ca $OBJ/revoked-ca.pub \ |
95 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 99 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
96 | # KRLs from serial/key-id spec need the CA specified. | 100 | # This should fail as KRLs from serial/key-id spec need the CA specified. |
97 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial $OBJ/revoked-serials \ | 101 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial $OBJ/revoked-serials \ |
98 | >/dev/null 2>&1 && fatal "$SSHKEYGEN KRL succeeded unexpectedly" | 102 | >/dev/null 2>&1 && fatal "$SSHKEYGEN KRL succeeded unexpectedly" |
99 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid $OBJ/revoked-keyid \ | 103 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid $OBJ/revoked-keyid \ |
100 | >/dev/null 2>&1 && fatal "$SSHKEYGEN KRL succeeded unexpectedly" | 104 | >/dev/null 2>&1 && fatal "$SSHKEYGEN KRL succeeded unexpectedly" |
101 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial -s $OBJ/revoked-ca $OBJ/revoked-serials \ | 105 | # These should succeed; they specify an explicit CA key. |
106 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial -s $OBJ/revoked-ca \ | ||
107 | $OBJ/revoked-serials >/dev/null || fatal "$SSHKEYGEN KRL failed" | ||
108 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid -s $OBJ/revoked-ca.pub \ | ||
109 | $OBJ/revoked-keyid >/dev/null || fatal "$SSHKEYGEN KRL failed" | ||
110 | # These should succeed; they specify an wildcard CA key. | ||
111 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial-wild -s NONE $OBJ/revoked-serials \ | ||
102 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 112 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
103 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid -s $OBJ/revoked-ca.pub $OBJ/revoked-keyid \ | 113 | $SSHKEYGEN $OPTS -kf $OBJ/krl-keyid-wild -s NONE $OBJ/revoked-keyid \ |
104 | >/dev/null || fatal "$SSHKEYGEN KRL failed" | 114 | >/dev/null || fatal "$SSHKEYGEN KRL failed" |
115 | # Revoke the same serials with the second CA key to ensure a multi-CA | ||
116 | # KRL is generated. | ||
117 | $SSHKEYGEN $OPTS -kf $OBJ/krl-serial -u -s $OBJ/revoked-ca2 \ | ||
118 | $OBJ/revoked-serials >/dev/null || fatal "$SSHKEYGEN KRL failed" | ||
105 | } | 119 | } |
106 | 120 | ||
107 | ## XXX dump with trace and grep for set cert serials | 121 | ## XXX dump with trace and grep for set cert serials |
@@ -123,7 +137,7 @@ check_krl() { | |||
123 | fatal "key $KEY unexpectedly revoked by KRL $KRL: $TAG" | 137 | fatal "key $KEY unexpectedly revoked by KRL $KRL: $TAG" |
124 | fi | 138 | fi |
125 | } | 139 | } |
126 | test_all() { | 140 | test_rev() { |
127 | FILES=$1 | 141 | FILES=$1 |
128 | TAG=$2 | 142 | TAG=$2 |
129 | KEYS_RESULT=$3 | 143 | KEYS_RESULT=$3 |
@@ -132,32 +146,40 @@ test_all() { | |||
132 | KEYID_RESULT=$6 | 146 | KEYID_RESULT=$6 |
133 | CERTS_RESULT=$7 | 147 | CERTS_RESULT=$7 |
134 | CA_RESULT=$8 | 148 | CA_RESULT=$8 |
149 | SERIAL_WRESULT=$9 | ||
150 | KEYID_WRESULT=$10 | ||
135 | verbose "$tid: checking revocations for $TAG" | 151 | verbose "$tid: checking revocations for $TAG" |
136 | for f in $FILES ; do | 152 | for f in $FILES ; do |
137 | check_krl $f $OBJ/krl-empty no "$TAG" | 153 | check_krl $f $OBJ/krl-empty no "$TAG" |
138 | check_krl $f $OBJ/krl-keys $KEYS_RESULT "$TAG" | 154 | check_krl $f $OBJ/krl-keys $KEYS_RESULT "$TAG" |
139 | check_krl $f $OBJ/krl-all $ALL_RESULT "$TAG" | 155 | check_krl $f $OBJ/krl-all $ALL_RESULT "$TAG" |
140 | check_krl $f $OBJ/krl-serial $SERIAL_RESULT "$TAG" | 156 | check_krl $f $OBJ/krl-serial $SERIAL_RESULT "$TAG" |
141 | check_krl $f $OBJ/krl-keyid $KEYID_RESULT "$TAG" | 157 | check_krl $f $OBJ/krl-keyid $KEYID_RESULT "$TAG" |
142 | check_krl $f $OBJ/krl-cert $CERTS_RESULT "$TAG" | 158 | check_krl $f $OBJ/krl-cert $CERTS_RESULT "$TAG" |
143 | check_krl $f $OBJ/krl-ca $CA_RESULT "$TAG" | 159 | check_krl $f $OBJ/krl-ca $CA_RESULT "$TAG" |
160 | check_krl $f $OBJ/krl-serial-wild $SERIAL_WRESULT "$TAG" | ||
161 | check_krl $f $OBJ/krl-keyid-wild $KEYID_WRESULT "$TAG" | ||
144 | done | 162 | done |
145 | } | 163 | } |
146 | # keys all serial keyid certs CA | 164 | |
147 | test_all "$REVOKED_KEYS" "revoked keys" yes yes no no no no | 165 | test_all() { |
148 | test_all "$UNREVOKED_KEYS" "unrevoked keys" no no no no no no | 166 | # wildcard |
149 | test_all "$REVOKED_CERTS" "revoked certs" yes yes yes yes yes yes | 167 | # keys all sr# k.ID cert CA sr.# k.ID |
150 | test_all "$UNREVOKED_CERTS" "unrevoked certs" no no no no no yes | 168 | test_rev "$RKEYS" "revoked keys" yes yes no no no no no no |
169 | test_rev "$UKEYS" "unrevoked keys" no no no no no no no no | ||
170 | test_rev "$RCERTS" "revoked certs" yes yes yes yes yes yes yes yes | ||
171 | test_rev "$UCERTS" "unrevoked certs" no no no no no yes no no | ||
172 | } | ||
173 | |||
174 | test_all | ||
151 | 175 | ||
152 | # Check update. Results should be identical. | 176 | # Check update. Results should be identical. |
153 | verbose "$tid: testing KRL update" | 177 | verbose "$tid: testing KRL update" |
154 | for f in $OBJ/krl-keys $OBJ/krl-cert $OBJ/krl-all \ | 178 | for f in $OBJ/krl-keys $OBJ/krl-cert $OBJ/krl-all \ |
155 | $OBJ/krl-ca $OBJ/krl-serial $OBJ/krl-keyid ; do | 179 | $OBJ/krl-ca $OBJ/krl-serial $OBJ/krl-keyid \ |
180 | $OBJ/krl-serial-wild $OBJ/krl-keyid-wild; do | ||
156 | cp -f $OBJ/krl-empty $f | 181 | cp -f $OBJ/krl-empty $f |
157 | genkrls -u | 182 | genkrls -u |
158 | done | 183 | done |
159 | # keys all serial keyid certs CA | 184 | |
160 | test_all "$REVOKED_KEYS" "revoked keys" yes yes no no no no | 185 | test_all |
161 | test_all "$UNREVOKED_KEYS" "unrevoked keys" no no no no no no | ||
162 | test_all "$REVOKED_CERTS" "revoked certs" yes yes yes yes yes yes | ||
163 | test_all "$UNREVOKED_CERTS" "unrevoked certs" no no no no no yes | ||