Update p11sak-key-management-tool-basic-functionality for v3.21.0
This commit is contained in:
parent
5dbe066eb3
commit
c2ba47eaa9
1 changed files with 67 additions and 18 deletions
|
|
@ -52,26 +52,43 @@ rlJournalStart
|
|||
|
||||
rlPhaseStartTest "Test key generation and listing"
|
||||
rlRun -s "p11sak generate-key aes 128 --slot $SLOT --pin $pkcsUSER_PIN --label aes_key --attr ED"
|
||||
rlAssertGrep 'Generate symmetric key AES with keylen=128 and label="?\[aes_key\]"?' $rlRun_LOG -E
|
||||
rlAssertGrep "Symmetric key generation successful!" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep 'Generate symmetric key AES with keylen=128 and label="?\[aes_key\]"?' $rlRun_LOG -E
|
||||
rlAssertGrep "Symmetric key generation successful!" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully generated a AES key with label "aes_key".' $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak list-key aes --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep 'AES 128 | "?aes_key"?' $rlRun_LOG -E
|
||||
|
||||
rlRun -s "p11sak gen-key 3des --slot $SLOT --pin $pkcsUSER_PIN --label 3des_key"
|
||||
rlAssertGrep 'Generate symmetric key 3DES with keylen=192 and label="?\[3des_key\]"?' $rlRun_LOG -E
|
||||
rlAssertGrep "Symmetric key generation successful!" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep 'Generate symmetric key 3DES with keylen=192 and label="?\[3des_key\]"?' $rlRun_LOG -E
|
||||
rlAssertGrep "Symmetric key generation successful!" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully generated a 3DES key with label "3des_key".' $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key 3des --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep '3DES | "?3des_key"?' $rlRun_LOG -E
|
||||
|
||||
rlRun -s "p11sak gen-key rsa 2048 --exponent 65537 --slot $SLOT --pin $pkcsUSER_PIN --label rsa_key"
|
||||
rlAssertGrep "Generate asymmetric key: RSA_PKCS" $rlRun_LOG
|
||||
rlAssertGrep "Asymmetric key pair generation successful!" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlRun -s "p11sak gen-key rsa 2048 --exponent 65537 --slot $SLOT --pin $pkcsUSER_PIN --label rsa_key"
|
||||
rlAssertGrep "Generate asymmetric key: RSA_PKCS" $rlRun_LOG
|
||||
rlAssertGrep "Asymmetric key pair generation successful!" $rlRun_LOG
|
||||
else
|
||||
rlRun -s "p11sak gen-key rsa 2048 65537 --slot $SLOT --pin $pkcsUSER_PIN --label rsa_key"
|
||||
rlAssertGrep 'Successfully generated a RSA key pair with labels "rsa_key:pub":"rsa_key:prv".' $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key rsa --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep 'public RSA | "?rsa_key:pub"?' $rlRun_LOG -E
|
||||
rlAssertGrep 'private RSA | "?rsa_key:prv"?' $rlRun_LOG -E
|
||||
|
||||
rlRun -s "p11sak gen-key ec prime256v1 --slot $SLOT --pin $pkcsUSER_PIN --label ec_key"
|
||||
rlAssertGrep "Generate asymmetric key: EC" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Generate asymmetric key: EC" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully generated a EC key pair with labels "ec_key:pub":"ec_key:prv".' $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls secret --long --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep 'Label: "?aes_key"?' $rlRun_LOG -E
|
||||
rlAssertGrep 'Label: "?3des_key"?' $rlRun_LOG -E
|
||||
|
|
@ -94,34 +111,66 @@ attribute {
|
|||
|
||||
_EOF"
|
||||
rlRun -s "p11sak ls private --long --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep "CKA_PRIME_1: len=128 value:" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "CKA_PRIME_1: len=128 value:" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep "CKA_PRIME_1: \[sensitive\]" $rlRun_LOG
|
||||
fi
|
||||
rlPhaseEnd
|
||||
fi
|
||||
|
||||
if nvrTestPackage opencryptoki '>=' 3.15.0; then
|
||||
rlPhaseStartTest "Test key removal"
|
||||
rlRun -s "echo '' | p11sak remove-key aes --slot $SLOT --pin $pkcsUSER_PIN --label aes_key"
|
||||
rlAssertGrep "Skip deleting Key. User input CKR_CANCEL" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlRun -s "echo '' | p11sak remove-key aes --slot $SLOT --pin $pkcsUSER_PIN --label aes_key"
|
||||
else
|
||||
rlFail "failing here so we won't forget to remove the workaround"
|
||||
rlRun -s "echo 'n' | p11sak remove-key aes --slot $SLOT --pin $pkcsUSER_PIN --label aes_key"
|
||||
fi
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Skip deleting Key. User input CKR_CANCEL" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep "1 key object(s) skipped." $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key aes --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep "aes_key" $rlRun_LOG
|
||||
|
||||
rlRun -s "echo n | p11sak remove-key aes --slot $SLOT --pin $pkcsUSER_PIN --label aes_key"
|
||||
rlAssertGrep "Skip deleting Key" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Skip deleting Key" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep "1 key object(s) skipped." $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key aes --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertGrep "aes_key" $rlRun_LOG
|
||||
|
||||
rlRun -s "echo y | p11sak remove-key aes --slot $SLOT --pin $pkcsUSER_PIN --label aes_key"
|
||||
rlAssertGrep "Object with Label: aes_key found and destroyed" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Object with Label: aes_key found and destroyed" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully removed AES 128 key object "aes_key".' $rlRun_LOG
|
||||
rlAssertGrep "1 key object(s) removed." $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key aes --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertNotGrep "aes_key" $rlRun_LOG
|
||||
|
||||
rlRun -s "p11sak rm-key 3des --force --slot $SLOT --pin $pkcsUSER_PIN --label 3des_key"
|
||||
rlAssertGrep "Object with Label: 3des_key found and destroyed" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Object with Label: 3des_key found and destroyed" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully removed 3DES key object "3des_key".' $rlRun_LOG
|
||||
rlAssertGrep "1 key object(s) removed." $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key 3des --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertNotGrep "3des_key" $rlRun_LOG
|
||||
|
||||
rlRun -s "p11sak rm rsa --force --slot $SLOT --pin $pkcsUSER_PIN --label rsa_key:pub"
|
||||
rlAssertGrep "Object with Label: rsa_key:pub found and destroyed" $rlRun_LOG
|
||||
if nvrTestPackage opencryptoki '<' 3.21.0; then
|
||||
rlAssertGrep "Object with Label: rsa_key:pub found and destroyed" $rlRun_LOG
|
||||
else
|
||||
rlAssertGrep 'Successfully removed public RSA 2048 key object "rsa_key:pub".' $rlRun_LOG
|
||||
rlAssertGrep "1 key object(s) removed." $rlRun_LOG
|
||||
fi
|
||||
rlRun -s "p11sak ls-key rsa --slot $SLOT --pin $pkcsUSER_PIN"
|
||||
rlAssertNotGrep "rsa_key:pub" $rlRun_LOG
|
||||
rlPhaseEnd
|
||||
|
|
@ -131,15 +180,15 @@ fi
|
|||
rlRun -s "p11sak --help"
|
||||
rlAssertGrep "Usage: p11sak COMMAND \[ARGS\] \[OPTIONS\]" $rlRun_LOG
|
||||
|
||||
rlRun -s "p11sak generate-key --help" 7
|
||||
rlRun -s "p11sak generate-key --help" 0,7
|
||||
rlAssertGrep "Usage: p11sak generate-key \[ARGS\] \[OPTIONS\]" $rlRun_LOG
|
||||
|
||||
rlRun -s "p11sak list-key --help" 7
|
||||
rlRun -s "p11sak list-key --help" 0,7
|
||||
rlAssertGrep "Usage: p11sak list-key \[ARGS\] \[OPTIONS\]" $rlRun_LOG
|
||||
|
||||
|
||||
if nvrTestPackage opencryptoki '>=' 3.15.0; then
|
||||
rlRun -s "p11sak remove-key --help" 7
|
||||
rlRun -s "p11sak remove-key --help" 0,7
|
||||
rlAssertGrep "Usage: p11sak remove-key \[ARGS\] \[OPTIONS\]" $rlRun_LOG
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue