Debian Codegraph @

tests/case-insensitive.softhsm

raw
1 #!/bin/bash
2
3 # Copyright © 2024 Mobi - Com Polska Sp. z o.o.
4 # Author: Małgorzata Olszówka <[email protected]>
5 # Copyright (C) 2015 Nikos Mavrogiannopoulos
6 # Copyright (C) 2018 Anderson Toshiyuki Sasaki
7 #
8 # GnuTLS is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by the
10 # Free Software Foundation; either version 3 of the License, or (at
11 # your option) any later version.
12 #
13 # GnuTLS is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GnuTLS; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22 # This test if the PKCS#11 URI scheme detection is case insensitive
23
24 outdir="output.$$"
25
26 ALL_LOWER_PRIV_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=private;pin-value=1234"
27 ALL_LOWER_PUB_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=public;pin-value=1234"
28
29 ALL_UPPER_PRIV_KEY="PKCS11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=private;pin-value=1234"
30 ALL_UPER_PUB_KEY="PKCS11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=public;pin-value=1234"
31
32 MIXED_PRIV_KEY="PkCs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=private;pin-value=1234"
33 MIXED_PUB_KEY="pKcS11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=public;pin-value=1234"
34
35 # Load common test functions
36 . ${srcdir}/common.sh
37
38 # Do the token initialization
39 init_token "rsa" "1" "libp11" ${ID} "server-key" "privkey" "pubkey" "cert"
40
41 # Load openssl settings
42 . ${srcdir}/openssl-settings.sh
43
44 # Restore openssl settings
45 trap cleanup EXIT
46
47 # Run the test
48 ${WRAPPER} ./evp-sign default false "${outdir}/engines.cnf" \
49 ${ALL_LOWER_PRIV_KEY} ${ALL_LOWER_PUB_KEY} ${MODULE}
50 rc=$?
51 if [[ $rc -eq 77 ]]; then
52 echo "PKCS#11 URI scheme detection test skipped."
53 rm -rf "$outdir"
54 exit 77
55 elif [[ $rc -ne 0 ]]; then
56 echo "All lower case PKCS#11 URI scheme detection failed."
57 exit 1
58 fi
59
60 ./evp-sign default false "${outdir}/engines.cnf" \
61 ${ALL_UPPER_PRIV_KEY} ${ALL_UPER_PUB_KEY} ${MODULE}
62 if [[ $? -ne 0 ]]; then
63 echo "All upper case PKCS#11 URI scheme detection failed."
64 exit 1
65 fi
66
67 ./evp-sign default false "${outdir}/engines.cnf" \
68 ${MIXED_PRIV_KEY} ${MIXED_PUB_KEY} ${MODULE}
69 if [[ $? -ne 0 ]]; then
70 echo "Mixed case PKCS#11 URI scheme detection failed."
71 exit 1
72 fi
73
74 rm -rf "$outdir"
75
76 exit 0