]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use unique SoftHSMv2 token label for the "keyfromlabel" test
authorAram Sargsyan <aram@isc.org>
Thu, 3 Feb 2022 10:59:45 +0000 (10:59 +0000)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 4 Feb 2022 12:40:18 +0000 (13:40 +0100)
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.

bin/tests/system/keyfromlabel/clean.sh
bin/tests/system/keyfromlabel/setup.sh
bin/tests/system/keyfromlabel/tests.sh

index 39082d4ce24d8abf18d6b56910bfb0109aa1e7b5..bce20990be628a9177c82635a7d40aff55b30e79 100644 (file)
@@ -24,4 +24,4 @@ rm -f keyfromlabel.out.*
 rm -f pkcs11-tool.out.*
 rm -f signer.out.*
 
-softhsm2-util --delete-token --token "softhsm2" || echo_i "softhsm2 token not found"
+softhsm2-util --delete-token --token "softhsm2-keyfromlabel" >/dev/null 2>&1 || echo_i "softhsm2-keyfromlabel token not found for cleaning"
index 9f06a71faf5cc7ee5ec2ab230fd69d9ea5d71bea..703814d62dd1ac36b805fa931ef220c6d141b286 100644 (file)
@@ -16,7 +16,7 @@
 
 set -e
 
-softhsm2-util --init-token --free --pin 1234 --so-pin 1234 --label "softhsm2" | awk '/^The token has been initialized and is reassigned to slot/ { print $NF }'
+softhsm2-util --init-token --free --pin 1234 --so-pin 1234 --label "softhsm2-keyfromlabel" | awk '/^The token has been initialized and is reassigned to slot/ { print $NF }'
 
 printf '%s' "${HSMPIN:-1234}" > pin
 PWD=$(pwd)
index b54ea7b06c5622e58f769a3d2960de38c3200464..247eefe688bd86d2dc3c88caf70800d5b65d5ff8 100644 (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
 }