Debian Codegraph @

tests/rsa-oaep.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 # 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 <http://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 PUBLIC_KEY="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0;type=public;pin-value=1234"
25
26 # Load common test functions
27 . ${srcdir}/common.sh
28
29 # Do the token initialization
30 init_token "rsa" "1" "libp11" ${ID} "server-key" "privkey" "pubkey" "cert"
31
32 # Load openssl settings
33 . ${srcdir}/openssl-settings.sh
34
35 # Restore openssl settings
36 trap cleanup EXIT
37
38 # Run the test
39 ${WRAPPER} ./rsa-oaep ${PIN} "${outdir}/engines.cnf" \
40 ${PRIVATE_KEY} ${PUBLIC_KEY} ${MODULE}
41 rc=$?
42 if [[ $rc -eq 77 ]]; then
43 echo "RSA-OAEP encryption/decryption test skipped."
44 rm -rf "$outdir"
45 exit 77
46 elif [[ $rc -ne 0 ]]; then
47 echo "RSA-OAEP encryption/decryption test failed."
48 exit 1
49 fi
50
51 rm -rf "$outdir"
52
53 exit 0