Use unique SoftHSMv2 token label for the "keyfromlabel" test

When there are more than one tokens initialized in SoftHSMv2,
care must be taken to correctly identify them.

Use a SoftHSMv2 token label which will uniquely identify the
token used for this test.

Use the "--token-label" parameter for the `pkcs11-tool` program
to make sure that it finds and uses the correct token.
This commit is contained in:
Aram Sargsyan
2022-02-03 10:59:45 +00:00
committed by Matthijs Mekking
parent 468cf3cdc2
commit a449709441
3 changed files with 4 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ keygen() {
label="${id}-${zone}"
p11id=$(echo "${label}" | sha1sum - | awk '{print $1}')
pkcs11-tool --module $SOFTHSM2_MODULE -l -k --key-type $type:$bits --label "${label}" --id "${p11id//$'\n'/}" --pin $(cat $PWD/pin) > pkcs11-tool.out.$zone.$id || return 1
pkcs11-tool --module $SOFTHSM2_MODULE --token-label "softhsm2-keyfromlabel" -l -k --key-type $type:$bits --label "${label}" --id "${p11id//$'\n'/}" --pin $(cat $PWD/pin) > pkcs11-tool.out.$zone.$id || return 1
}
keyfromlabel() {
@@ -33,7 +33,7 @@ keyfromlabel() {
id="$3"
shift 3
$KEYFRLAB -E pkcs11 -a $alg -l "token=softhsm2;object=${id}-${zone};pin-source=$PWD/pin" "$@" $zone >> keyfromlabel.out.$zone.$id 2>> /dev/null || return 1
$KEYFRLAB -E pkcs11 -a $alg -l "token=softhsm2-keyfromlabel;object=${id}-${zone};pin-source=$PWD/pin" "$@" $zone >> keyfromlabel.out.$zone.$id 2>> /dev/null || return 1
cat keyfromlabel.out.$zone.$id
}