| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Copyright © 2024 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 <https://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
outdir="output.$$" |
| 20 |
|
| 21 |
# Load common test functions |
| 22 |
. ${srcdir}/common.sh |
| 23 |
|
| 24 |
# Initialize SoftHSM DB |
| 25 |
init_db |
| 26 |
|
| 27 |
# Create token |
| 28 |
init_card "token1" |
| 29 |
|
| 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 |
${WRAPPER} ./ed25519-keygen-prov ${MODULE} token1 libp11-keylabel ${PIN} |
| 43 |
rc=$? |
| 44 |
if [[ $rc -eq 77 ]]; then |
| 45 |
echo "Ed25519 key generation test skipped." |
| 46 |
rm -rf "$outdir" |
| 47 |
exit 77 |
| 48 |
elif [[ $rc -ne 0 ]]; then |
| 49 |
echo "Ed25519 key generation test failed." |
| 50 |
exit 1 |
| 51 |
fi |
| 52 |
|
| 53 |
echo "Checking pkcs11-tool result..." |
| 54 |
list_objects | grep -q libp11-keylabel |
| 55 |
if [[ $? != 0 ]]; then |
| 56 |
echo "Ed25519 key was not properly generated." |
| 57 |
exit 1 |
| 58 |
fi |
| 59 |
|
| 60 |
rm -rf "$outdir" |
| 61 |
|
| 62 |
exit 0 |