mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2024-09-20 03:10:09 +00:00
Add initialize with pkcs11-tool test script.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
9f08d612ae
commit
433e509c94
44
tests/scripts/initialize.sh
Executable file
44
tests/scripts/initialize.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
python3 tools/pico-hsm-tool.py --pin 648219 initialize --so-pin 57621880 --silent
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
# Change SO-PIN
|
||||
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --change-pin --new-pin 0123456789012345
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
pkcs11-tool --login --login-type so --so-pin 0123456789012345 --change-pin --new-pin 3537363231383830
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
# Change PIN
|
||||
pkcs11-tool --login --pin 648219 --change-pin --new-pin 123456
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
# Reset PIN
|
||||
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --init-pin --new-pin 648219
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
# Change PIN
|
||||
pkcs11-tool --login --pin 648219 --change-pin --new-pin 123456
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
pkcs11-tool --login --pin 123456 --change-pin --new-pin 648219
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
# Wrong PIN (1st and 2nd PIN_INCORRECT, 3rd PIN_LOCKED)
|
||||
e=$(pkcs11-tool --login --pin 123456 -I 2>&1)
|
||||
test $? -eq 1 || exit $?
|
||||
grep -q CKR_PIN_INCORRECT <<< $e || exit $?
|
||||
e=$(pkcs11-tool --login --pin 123456 -I 2>&1)
|
||||
test $? -eq 1 || exit $?
|
||||
grep -q CKR_PIN_INCORRECT <<< $e || exit $?
|
||||
e=$(pkcs11-tool --login --pin 123456 -I 2>&1)
|
||||
test $? -eq 1 || exit $?
|
||||
grep -q CKR_PIN_LOCKED <<< $e || exit $?
|
||||
|
||||
# Reset PIN
|
||||
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --init-pin --new-pin 648219
|
||||
test $? -eq 0 || exit $?
|
||||
|
||||
pkcs11-tool --login --pin 648219 -I > /dev/null
|
||||
test $? -eq 0 || exit $?
|
@ -8,4 +8,11 @@ sleep 2
|
||||
rm -f memory.flash
|
||||
tar -xf tests/memory.tar.gz
|
||||
./build_in_docker/pico_hsm > /dev/null &
|
||||
pytest tests -W ignore::DeprecationWarning
|
||||
#pytest tests -W ignore::DeprecationWarning
|
||||
|
||||
chmod a+x tests/scripts/*.sh
|
||||
|
||||
echo -n "Test initialization... "
|
||||
./tests/scripts/initialize.sh
|
||||
echo "\tok"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user