@@ -1,8 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
OK="\033[32mok\033[0m"
|
||||
FAIL="\033[31mfail\033[0m"
|
||||
|
||||
gen_and_check() {
|
||||
e=$(pkcs11-tool -l --pin 648219 --keypairgen --key-type $1 --id 1 --label "TestLabel" 2>&1)
|
||||
test $? -eq 0 || exit $?
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
glabel=""
|
||||
case $1 in
|
||||
*"192"*)
|
||||
@@ -25,13 +28,25 @@ gen_and_check() {
|
||||
glabel="RSA ${bits} bits"
|
||||
;;
|
||||
esac
|
||||
grep -q "${glabel}" <<< $e || exit $?
|
||||
grep -q "${glabel}" <<< $e && echo -n "." || exit $?
|
||||
}
|
||||
gen_and_delete() {
|
||||
gen_and_check $1
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
pkcs11-tool -l --pin 648219 --delete-object --type privkey --id 1 > /dev/null 2>&1
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
}
|
||||
reset() {
|
||||
python3 tools/pico-hsm-tool.py --pin 648219 initialize --so-pin 57621880 --silent > /dev/null 2>&1
|
||||
test $? -eq 0 || exit $?
|
||||
}
|
||||
|
||||
keygen_and_export() {
|
||||
gen_and_check $1
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
pkcs11-tool --read-object --pin 648219 --id 1 --type pubkey > 1.der 2>/dev/null
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
IFS=: read -r mk bts <<< "$1"
|
||||
openssl ${mk} -inform DER -outform PEM -in 1.der -pubin > 1.pub 2>/dev/null
|
||||
test $? -eq 0 && echo -n "." || exit $?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user