Debian Codegraph @

tests/provider-rsa-pss-sign.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 PUBLIC_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=public"
26
27 # Do the token initialization
28 init_token "rsa" "1" "libp11" ${ID} "server-key" "privkey" "pubkey" "cert"
29
30 # Ensure the use of the locally built provider; applies after running 'pkcs11-tool'
31 unset OPENSSL_ENGINES
32 export OPENSSL_MODULES="../src/.libs/"
33 export PKCS11_MODULE_PATH=${MODULE}
34 echo "OPENSSL_MODULES=${OPENSSL_MODULES}"
35 echo "PKCS11_MODULE_PATH=${PKCS11_MODULE_PATH}"
36
37 # Load openssl settings
38 . ${srcdir}/openssl-settings.sh
39
40 # Restore openssl settings
41 trap cleanup EXIT
42
43 # Run the test
44 ${WRAPPER} ./rsa-pss-sign-prov ${PRIVATE_KEY} ${PUBLIC_KEY}
45 rc=$?
46 if [[ $rc -eq 77 ]]; then
47 echo "RSA-PSS signature/verification test skipped."
48 rm -rf "$outdir"
49 exit 77
50 elif [[ $rc -ne 0 ]]; then
51 echo "RSA-PSS signature/verification test failed."
52 exit 1
53 fi
54
55 rm -rf "$outdir"
56
57 exit 0