Skip to content

Commit a55a906

Browse files
committed
Add tests dedicated to pin-source
1 parent 22d5836 commit a55a906

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dist_check_SCRIPTS = \
4747
ec-keygen.softhsm \
4848
fork-change-slot.softhsm \
4949
case-insensitive.softhsm \
50+
pkcs11-uri-pin-source.softhsm \
5051
pkcs11-uri-without-token.softhsm \
5152
search-all-matching-tokens.softhsm \
5253
provider-rsa-evp-sign.softhsm \
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Copyright (C) 2025 Tobias Deiminger
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>
17+
18+
outdir="output.$$"
19+
20+
URL="pkcs11:token=libp11-0;id=%01%02%03%04;object=server-key-0"
21+
22+
# Load common test functions
23+
. ${srcdir}/common.sh
24+
25+
# Generate test input files
26+
printf ${PIN} > $outdir/pin.txt
27+
printf "${PIN}\n" > $outdir/pin_with_trailing_newline.txt
28+
29+
# Do the token initialization
30+
init_token "rsa" "1" "libp11" ${ID} "server-key" "privkey" "pubkey" "cert"
31+
32+
# Load openssl settings
33+
TEMP_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
34+
. ${srcdir}/openssl-settings.sh
35+
36+
# Run the test
37+
for PIN_SOURCE_ATTR in \
38+
"pin-source=$outdir/pin.txt" \
39+
"pin-source=$outdir/pin_with_trailing_newline.txt" \
40+
"pin-source=file:$outdir/pin.txt" \
41+
"pin-source=file:$outdir/pin_with_trailing_newline.txt"
42+
do
43+
44+
${WRAPPER} ./check-privkey "${URL};type=cert" "${URL};type=private;${PIN_SOURCE_ATTR}" \
45+
${MODULE} "${outdir}/engines.cnf"
46+
if [[ $? -ne 0 ]]; then
47+
echo "The private key loading couldn't get the public key from the certificate URL"
48+
exit 1
49+
fi
50+
51+
done
52+
53+
# Restore settings
54+
export LD_LIBRARY_PATH=${TEMP_LD_LIBRARY_PATH}
55+
56+
rm -rf "$outdir"
57+
58+
exit 0

0 commit comments

Comments
 (0)