1 1.1 elric #!/bin/sh 2 1.1 elric # 3 1.1 elric # Copyright (c) 2004 - 2006 Kungliga Tekniska Hgskolan 4 1.1 elric # (Royal Institute of Technology, Stockholm, Sweden). 5 1.1 elric # All rights reserved. 6 1.1 elric # 7 1.1 elric # Redistribution and use in source and binary forms, with or without 8 1.1 elric # modification, are permitted provided that the following conditions 9 1.1 elric # are met: 10 1.1 elric # 11 1.1 elric # 1. Redistributions of source code must retain the above copyright 12 1.1 elric # notice, this list of conditions and the following disclaimer. 13 1.1 elric # 14 1.1 elric # 2. Redistributions in binary form must reproduce the above copyright 15 1.1 elric # notice, this list of conditions and the following disclaimer in the 16 1.1 elric # documentation and/or other materials provided with the distribution. 17 1.1 elric # 18 1.1 elric # 3. Neither the name of the Institute nor the names of its contributors 19 1.1 elric # may be used to endorse or promote products derived from this software 20 1.1 elric # without specific prior written permission. 21 1.1 elric # 22 1.1 elric # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23 1.1 elric # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 1.1 elric # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 1.1 elric # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26 1.1 elric # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 1.1 elric # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 1.1 elric # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 1.1 elric # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 1.1 elric # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 1.1 elric # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 1.1 elric # SUCH DAMAGE. 33 1.1 elric # 34 1.1.1.2 elric # Id 35 1.1 elric # 36 1.1 elric 37 1.1 elric srcdir="@srcdir@" 38 1.1 elric objdir="@objdir@" 39 1.1 elric 40 1.1 elric stat="--statistic-file=${objdir}/statfile" 41 1.1 elric 42 1.1 elric hxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}" 43 1.1 elric if ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then 44 1.1 elric exit 77 45 1.1 elric fi 46 1.1 elric if ${hxtool} info | grep 'rand: not available' > /dev/null ; then 47 1.1 elric exit 77 48 1.1 elric fi 49 1.1 elric 50 1.1 elric echo "cert -> root" 51 1.1 elric ${hxtool} verify --missing-revoke \ 52 1.1 elric cert:FILE:$srcdir/data/test.crt \ 53 1.1 elric chain:FILE:$srcdir/data/test.crt \ 54 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 55 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 56 1.1 elric 57 1.1 elric echo "cert -> root" 58 1.1 elric ${hxtool} verify --missing-revoke \ 59 1.1 elric cert:FILE:$srcdir/data/test.crt \ 60 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 61 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 62 1.1 elric 63 1.1 elric echo "cert -> root" 64 1.1 elric ${hxtool} verify --missing-revoke \ 65 1.1 elric cert:FILE:$srcdir/data/test.crt \ 66 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 67 1.1 elric 68 1.1 elric echo "sub-cert -> root" 69 1.1 elric ${hxtool} verify --missing-revoke \ 70 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 71 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 72 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 73 1.1 elric 74 1.1 elric echo "sub-cert -> sub-ca -> root" 75 1.1 elric ${hxtool} verify --missing-revoke \ 76 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 77 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 78 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 79 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 80 1.1 elric 81 1.1 elric echo "sub-cert -> sub-ca" 82 1.1 elric ${hxtool} verify --missing-revoke \ 83 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 84 1.1 elric anchor:FILE:$srcdir/data/sub-ca.crt > /dev/null || exit 1 85 1.1 elric 86 1.1 elric echo "sub-cert -> sub-ca -> root" 87 1.1 elric ${hxtool} verify --missing-revoke \ 88 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 89 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 90 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 91 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 92 1.1 elric 93 1.1 elric echo "sub-cert -> sub-ca -> root" 94 1.1 elric ${hxtool} verify --missing-revoke \ 95 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 96 1.1 elric chain:FILE:$srcdir/data/ca.crt \ 97 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 98 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 99 1.1 elric 100 1.1 elric echo "sub-cert -> sub-ca -> root" 101 1.1 elric ${hxtool} verify --missing-revoke \ 102 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 103 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 104 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 105 1.1 elric 106 1.1 elric echo "max depth 2 (ok)" 107 1.1 elric ${hxtool} verify --missing-revoke \ 108 1.1 elric --max-depth=2 \ 109 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 110 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 111 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 112 1.1 elric 113 1.1 elric echo "max depth 1 (fail)" 114 1.1 elric ${hxtool} verify --missing-revoke \ 115 1.1 elric --max-depth=1 \ 116 1.1 elric cert:FILE:$srcdir/data/sub-cert.crt \ 117 1.1 elric chain:FILE:$srcdir/data/sub-ca.crt \ 118 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 119 1.1 elric 120 1.1 elric echo "ocsp non-ca responder" 121 1.1 elric ${hxtool} verify \ 122 1.1 elric cert:FILE:$srcdir/data/test.crt \ 123 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 124 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp1-ocsp.der > /dev/null || exit 1 125 1.1 elric 126 1.1 elric echo "ocsp ca responder" 127 1.1 elric ${hxtool} verify \ 128 1.1 elric cert:FILE:$srcdir/data/test.crt \ 129 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 130 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp1-ca.der > /dev/null || exit 1 131 1.1 elric 132 1.1 elric echo "ocsp no-ca responder, missing cert" 133 1.1 elric ${hxtool} verify \ 134 1.1 elric cert:FILE:$srcdir/data/test.crt \ 135 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 136 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp1-ocsp-no-cert.der > /dev/null && exit 1 137 1.1 elric 138 1.1 elric echo "ocsp no-ca responder, missing cert, in pool" 139 1.1 elric ${hxtool} verify \ 140 1.1 elric cert:FILE:$srcdir/data/test.crt \ 141 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 142 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp1-ocsp-no-cert.der \ 143 1.1 elric chain:FILE:$srcdir/data/ocsp-responder.crt > /dev/null || exit 1 144 1.1 elric 145 1.1 elric echo "ocsp no-ca responder, keyHash" 146 1.1 elric ${hxtool} verify \ 147 1.1 elric cert:FILE:$srcdir/data/test.crt \ 148 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 149 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp1-keyhash.der > /dev/null || exit 1 150 1.1 elric 151 1.1 elric echo "ocsp revoked cert" 152 1.1 elric ${hxtool} verify \ 153 1.1 elric cert:FILE:$srcdir/data/revoke.crt \ 154 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 155 1.1 elric ocsp:FILE:$srcdir/data/ocsp-resp2.der > /dev/null && exit 1 156 1.1 elric 157 1.1 elric for a in resp1-ocsp-no-cert resp1-ca resp1-keyhash resp2 ; do 158 1.1 elric echo "ocsp print reply $a" 159 1.1 elric ${hxtool} ocsp-print \ 160 1.1 elric $srcdir/data/ocsp-${a}.der > /dev/null || exit 1 161 1.1 elric done 162 1.1 elric 163 1.1 elric echo "ocsp verify exists" 164 1.1 elric ${hxtool} ocsp-verify \ 165 1.1 elric --ocsp-file=$srcdir/data/ocsp-resp1-ca.der \ 166 1.1 elric FILE:$srcdir/data/test.crt > /dev/null || exit 1 167 1.1 elric 168 1.1 elric echo "ocsp verify not exists" 169 1.1 elric ${hxtool} ocsp-verify \ 170 1.1 elric --ocsp-file=$srcdir/data/ocsp-resp1.der \ 171 1.1 elric FILE:$srcdir/data/ca.crt > /dev/null && exit 1 172 1.1 elric 173 1.1 elric echo "ocsp verify revoked" 174 1.1 elric ${hxtool} ocsp-verify \ 175 1.1 elric --ocsp-file=$srcdir/data/ocsp-resp2.der \ 176 1.1 elric FILE:$srcdir/data/revoke.crt > /dev/null && exit 1 177 1.1 elric 178 1.1 elric echo "crl non-revoked cert" 179 1.1 elric ${hxtool} verify \ 180 1.1 elric cert:FILE:$srcdir/data/test.crt \ 181 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 182 1.1 elric crl:FILE:$srcdir/data/crl1.der > /dev/null || exit 1 183 1.1 elric 184 1.1 elric echo "crl revoked cert" 185 1.1 elric ${hxtool} verify \ 186 1.1 elric cert:FILE:$srcdir/data/revoke.crt \ 187 1.1 elric anchor:FILE:$srcdir/data/ca.crt \ 188 1.1 elric crl:FILE:$srcdir/data/crl1.der > /dev/null && exit 1 189 1.1 elric 190 1.1 elric if ${hxtool} info | grep 'ecdsa: hcrypto null' > /dev/null ; then 191 1.1 elric echo "not testing ECDSA since hcrypto doesnt support ECDSA" 192 1.1 elric else 193 1.1 elric echo "eccert -> root" 194 1.1 elric ${hxtool} verify --missing-revoke \ 195 1.1.1.3 christos cert:FILE:$srcdir/data/secp256r2TestServer.cert.pem \ 196 1.1.1.3 christos anchor:FILE:$srcdir/data/secp256r1TestCA.cert.pem > /dev/null || exit 1 197 1.1 elric 198 1.1 elric echo "eccert -> root" 199 1.1 elric ${hxtool} verify --missing-revoke \ 200 1.1.1.3 christos cert:FILE:$srcdir/data/secp256r2TestClient.cert.pem \ 201 1.1.1.3 christos anchor:FILE:$srcdir/data/secp256r1TestCA.cert.pem > /dev/null || exit 1 202 1.1 elric fi 203 1.1 elric 204 1.1 elric echo "proxy cert" 205 1.1 elric ${hxtool} verify --missing-revoke \ 206 1.1 elric --allow-proxy-certificate \ 207 1.1 elric cert:FILE:$srcdir/data/proxy-test.crt \ 208 1.1 elric chain:FILE:$srcdir/data/test.crt \ 209 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 210 1.1 elric 211 1.1 elric echo "proxy cert (negative)" 212 1.1 elric ${hxtool} verify --missing-revoke \ 213 1.1 elric cert:FILE:$srcdir/data/proxy-test.crt \ 214 1.1 elric chain:FILE:$srcdir/data/test.crt \ 215 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 216 1.1 elric 217 1.1 elric echo "proxy cert (level fail)" 218 1.1 elric ${hxtool} verify --missing-revoke \ 219 1.1 elric --allow-proxy-certificate \ 220 1.1 elric cert:FILE:$srcdir/data/proxy-level-test.crt \ 221 1.1 elric chain:FILE:$srcdir/data/proxy-test.crt \ 222 1.1 elric chain:FILE:$srcdir/data/test.crt \ 223 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 224 1.1 elric 225 1.1 elric echo "not a proxy cert" 226 1.1 elric ${hxtool} verify --missing-revoke \ 227 1.1 elric --allow-proxy-certificate \ 228 1.1 elric cert:FILE:$srcdir/data/no-proxy-test.crt \ 229 1.1 elric chain:FILE:$srcdir/data/test.crt \ 230 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null && exit 1 231 1.1 elric 232 1.1 elric echo "proxy cert (max level 10)" 233 1.1 elric ${hxtool} verify --missing-revoke \ 234 1.1 elric --allow-proxy-certificate \ 235 1.1 elric cert:FILE:$srcdir/data/proxy10-test.crt \ 236 1.1 elric chain:FILE:$srcdir/data/test.crt \ 237 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 238 1.1 elric 239 1.1 elric echo "proxy cert (second level)" 240 1.1 elric ${hxtool} verify --missing-revoke \ 241 1.1 elric --allow-proxy-certificate \ 242 1.1 elric cert:FILE:$srcdir/data/proxy10-child-test.crt \ 243 1.1 elric chain:FILE:$srcdir/data/proxy10-test.crt \ 244 1.1 elric chain:FILE:$srcdir/data/test.crt \ 245 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 246 1.1 elric 247 1.1 elric echo "proxy cert (third level)" 248 1.1 elric ${hxtool} verify --missing-revoke \ 249 1.1 elric --allow-proxy-certificate \ 250 1.1 elric cert:FILE:$srcdir/data/proxy10-child-child-test.crt \ 251 1.1 elric chain:FILE:$srcdir/data/proxy10-child-test.crt \ 252 1.1 elric chain:FILE:$srcdir/data/proxy10-test.crt \ 253 1.1 elric chain:FILE:$srcdir/data/test.crt \ 254 1.1 elric anchor:FILE:$srcdir/data/ca.crt > /dev/null || exit 1 255 1.1 elric 256 1.1 elric exit 0 257