-
Notifications
You must be signed in to change notification settings - Fork 758
/
Copy pathtest-p11test.sh
executable file
·60 lines (47 loc) · 1.96 KB
/
test-p11test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
SOURCE_PATH=${SOURCE_PATH:-..}
source $SOURCE_PATH/tests/common.sh
echo "======================================================="
echo "Setup SoftHSM"
echo "======================================================="
if [[ ! -f $P11LIB ]]; then
echo "WARNING: The SoftHSM is not installed. Can not run this test"
exit 77;
fi
# The Ubuntu has old softhsm version not supporting this feature
grep "Ubuntu 18.04" /etc/issue && echo "WARNING: Not supported on Ubuntu 18.04" && exit 77
card_setup
assert $? "Failed to set up card"
echo "======================================================="
echo "Run p11test"
echo "======================================================="
$VALGRIND ./../src/tests/p11test/p11test -v -m $P11LIB -o softhsm.json -p $PIN
assert $? "Failed running tests"
# Run the input shrough sed to skip the mechanism part:
# * broken because of uninitialized memory in softhsm
# * different for different softhsm versions
# and interface tests
# * different results for softhsm and pkcs11-spy
function filter_log() {
sed -n '/readonly_tests/,$p' $1
}
REF_FILE="$SOURCE_PATH/tests/softhsm_ref.json"
if [[ -f "/proc/sys/crypto/fips_enabled" && $(cat /proc/sys/crypto/fips_enabled) == "1" ]]; then
REF_FILE="$SOURCE_PATH/tests/softhsm_fips_ref.json"
fi
diff -U3 <(filter_log $REF_FILE) <(filter_log softhsm.json)
assert $? "Unexpected results"
echo "======================================================="
echo "Run p11test with PKCS11SPY"
echo "======================================================="
export PKCS11SPY="$P11LIB"
$VALGRIND ./../src/tests/p11test/p11test -v -m ../src/pkcs11/.libs/pkcs11-spy.so -o softhsm.json -p $PIN
assert $? "Failed running tests"
diff -U3 <(filter_log $REF_FILE) <(filter_log softhsm.json)
assert $? "Unexpected results with PKCS11 spy"
rm softhsm.json
echo "======================================================="
echo "Cleanup"
echo "======================================================="
card_cleanup
exit $ERRORS