Debian Codegraph @

tests/ec-copy.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) 2022 Red Hat, Inc.
6 # Authors: Jakub Jelen <[email protected]>
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 outdir="output.$$"
22
23 PRIVATE_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=private;pin-value=1234"
24
25 # Load common test functions
26 . ${srcdir}/common.sh
27
28 # Do the token initialization
29 init_token "ec" "1" "libp11" ${ID} "server-key" "privkey" "" "cert"
30
31 # Load openssl settings
32 . ${srcdir}/openssl-settings.sh
33
34 # Restore openssl settings
35 trap cleanup EXIT
36
37 # Run the test
38 ${WRAPPER} ./dup-key ${PRIVATE_KEY} ${MODULE} "${outdir}/engines.cnf"
39 rc=$?
40 if [[ $rc -eq 77 ]]; then
41 echo "Duplicate private key test skipped."
42 rm -rf "$outdir"
43 exit 77
44 elif [[ $rc -ne 0 ]]; then
45 echo "Duplicate private key test failed."
46 exit 1
47 fi
48
49 rm -rf "$outdir"
50
51 exit 0