diff --git a/tests/scripts/pkcs11.sh b/tests/scripts/pkcs11.sh index c2292b8..bf625a2 100755 --- a/tests/scripts/pkcs11.sh +++ b/tests/scripts/pkcs11.sh @@ -28,3 +28,10 @@ test $? -eq 0 || { echo -e "\t${FAIL}" exit 1 } + +echo "==== Test binary storage ====" +./tests/scripts/store_binary.sh +test $? -eq 0 || { + echo -e "\t${FAIL}" + exit 1 +} diff --git a/tests/scripts/store_binary.sh b/tests/scripts/store_binary.sh new file mode 100755 index 0000000..2a116f1 --- /dev/null +++ b/tests/scripts/store_binary.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +source ./tests/scripts/func.sh +reset +test $? -eq 0 || exit $? + +TEST_DATA="Pico HSM is awesome!" + +echo 'Pico HSM is awesome!' > data + +echo -n " Test public binary storage..." +pkcs11-tool --pin 648219 --write-object test --type data --id 1 --label 'test1' > /dev/null 2>&1 +test $? -eq 0 && echo -n "." || exit $? +e=$(pkcs11-tool --read-object --type data --label 'test1' 2>&1) +test $? -eq 0 && echo -n "." || exit $? +grep -q "${TEST_DATA}" <<< $e && echo -e ".\t${OK}" || exit $? +pkcs11-tool --pin 648219 --delete-object --type data --label 'test1' > /dev/null 2>&1 + +echo -n " Test private binary storage..." +pkcs11-tool --pin 648219 --write-object test --type data --id 1 --label 'test1' --private > /dev/null 2>&1 +test $? -eq 0 && echo -n "." || exit $? +e=$(pkcs11-tool --read-object --type data --label 'test1' --pin 648219 2>&1) +test $? -eq 0 && echo -n "." || exit $? +grep -q "${TEST_DATA}" <<< $e && echo -n "." || exit $? +e=$(pkcs11-tool --read-object --type data --label 'test1' 2>&1) +test $? -eq 1 && echo -n "." || exit $? +grep -q "error: object not found" <<< $e && echo -e ".\t${OK}" || exit $? +pkcs11-tool --pin 648219 --delete-object --type data --label 'test1' > /dev/null 2>&1