Debian Codegraph @

tests/provider-ec-copy.softhsm

raw
1 #!/bin/bash
2
3 # Copyright © 2025 Mobi - Com Polska Sp. z o.o.
4 # Author: Małgorzata Olszówka <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>
18
19 outdir="output.$$"
20
21 # Load common test functions
22 . ${srcdir}/common.sh
23
24 PRIVATE_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=private;pin-value=${PIN}"
25
26 # Do the token initialization
27 init_token "ec" "1" "libp11" ${ID} "server-key" "privkey" "" ""
28
29 # Ensure the use of the locally built provider; applies after running 'pkcs11-tool'
30 unset OPENSSL_ENGINES
31 export OPENSSL_MODULES="../src/.libs/"
32 export PKCS11_MODULE_PATH=${MODULE}
33 echo "OPENSSL_MODULES=${OPENSSL_MODULES}"
34 echo "PKCS11_MODULE_PATH=${PKCS11_MODULE_PATH}"
35
36 # Load openssl settings
37 . ${srcdir}/openssl-settings.sh
38
39 # Restore openssl settings
40 trap cleanup EXIT
41
42 # Run the test
43 ${WRAPPER} ./dup-key-prov ${PRIVATE_KEY}
44 rc=$?
45 if [[ $rc -eq 77 ]]; then
46 echo "Duplicate private key test skipped."
47 rm -rf "$outdir"
48 exit 77
49 elif [[ $rc -ne 0 ]]; then
50 echo "Duplicate private key test failed."
51 exit 1
52 fi
53
54 rm -rf "$outdir"
55
56 exit 0