fapi-export-policy_ecc.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/myRSASign"
  12. POLICY_NAME=policy_pcr
  13. POLICY_DATA=$TEMP_DIR/pol_pcr16_0.json
  14. JSON_POLICY=policy/pcr-policy
  15. EXPORTED_POLICY=$TEMP_DIR/exported-pcr-policy
  16. tss2 provision
  17. tss2 import --path=$JSON_POLICY --importData=$POLICY_DATA
  18. tss2 createkey --path=$KEY_PATH --type="noDa, sign" --policyPath=$JSON_POLICY \
  19. --authValue=""
  20. tss2 exportpolicy --path=$KEY_PATH --jsonPolicy=$EXPORTED_POLICY --force
  21. if [ ! -s $EXPORTED_POLICY ]
  22. then
  23. echo "Exported policy is empty"
  24. exit 1
  25. fi
  26. expect <<EOF
  27. # Try with missing path
  28. spawn tss2 exportpolicy --jsonPolicy=$EXPORTED_POLICY
  29. set ret [wait]
  30. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  31. Command has not failed as expected\n"
  32. exit 1
  33. }
  34. EOF
  35. expect <<EOF
  36. # Try with missing jsonPolicy
  37. spawn tss2 exportpolicy --path=$KEY_PATH
  38. set ret [wait]
  39. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  40. Command has not failed as expected\n"
  41. exit 1
  42. }
  43. EOF
  44. exit 0