Debian Codegraph @

tests/ec-keygen.softhsm

raw
1 #!/bin/bash
2
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16 outdir="output.$$"
17
18 # Load common test functions
19 . ${srcdir}/common.sh
20
21 # Initialize SoftHSM DB
22 init_db
23
24 # Create 2 different tokens
25 init_card "token1"
26
27 # Load openssl settings
28 . ${srcdir}/openssl-settings.sh
29
30 # Restore openssl settings
31 trap cleanup EXIT
32
33 ${WRAPPER} ./ec-keygen token1 libp11-keylabel ${PIN} "${outdir}/engines.cnf" ${MODULE}
34 rc=$?
35 if [[ $rc -eq 77 ]]; then
36 echo "EC key generation test skipped."
37 rm -rf "$outdir"
38 exit 77
39 elif [[ $rc -ne 0 ]]; then
40 echo "EC key generation test failed."
41 exit 1
42 fi
43
44 echo "Checking pkcs11-tool result..."
45 list_objects | grep -q libp11-keylabel
46 if [[ $? != 0 ]]; then
47 echo "The key was not properly generated."
48 exit 1
49 fi
50
51 rm -rf "$outdir"
52
53 exit 0