fapi-set-get-description_ecc.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. set -e
  2. source helpers.sh
  3. start_up
  4. CRYPTO_PROFILE="ECC"
  5. setup_fapi $CRYPTO_PROFILE
  6. function cleanup {
  7. tss2 delete --path=/
  8. shut_down
  9. }
  10. trap cleanup EXIT
  11. KEY_PATH=HS/SRK/myRSACrypt
  12. # DESCRIPTION_SET=$TEMP_DIR/set_description.file
  13. DESCRIPTION_FILE=$TEMP_DIR/object_description.file
  14. DESCRIPTION_SET="description data"
  15. tss2 provision
  16. tss2 createkey --path=$KEY_PATH --type="noDa, restricted, decrypt" \
  17. --authValue=""
  18. tss2 setdescription --path=$KEY_PATH --description="$(echo $DESCRIPTION_SET)"
  19. tss2 getdescription --path=$KEY_PATH --description=$DESCRIPTION_FILE --force
  20. if [ "$(< $DESCRIPTION_FILE)" != "$DESCRIPTION_SET" ]; then
  21. echo "Descriptions not equal"
  22. exit 1
  23. fi
  24. expect <<EOF
  25. # Try with missing path
  26. spawn tss2 setdescription --description=$DESCRIPTION_SET
  27. set ret [wait]
  28. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  29. Command has not failed as expected\n"
  30. exit 1
  31. }
  32. EOF
  33. # Try with missing description, should set description to empty
  34. tss2 setdescription --path=$KEY_PATH
  35. tss2 getdescription --path=$KEY_PATH --description=$DESCRIPTION_FILE --force
  36. if [ "$(< $DESCRIPTION_FILE)" != "" ]; then
  37. echo "Description is not empty"
  38. exit 1
  39. fi
  40. expect <<EOF
  41. # Try with missing path
  42. spawn tss2 getdescription --description=$DESCRIPTION_FILE
  43. set ret [wait]
  44. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  45. Command has not failed as expected\n"
  46. exit 1
  47. }
  48. EOF
  49. expect <<EOF
  50. # Try with missing description
  51. spawn tss2 getdescription --path=$KEY_PATH
  52. set ret [wait]
  53. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  54. Command has not failed as expected\n"
  55. exit 1
  56. }
  57. EOF
  58. exit 0