fapi-get-random.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. set -e
  2. source helpers.sh
  3. start_up
  4. CRYPTO_PROFILE="RSA"
  5. setup_fapi $CRYPTO_PROFILE
  6. PATH=${abs_builddir}/tools/fapi:$PATH
  7. function cleanup {
  8. tss2 delete --path=/
  9. shut_down
  10. }
  11. trap cleanup EXIT
  12. OUTPUT_FILE="$TEMP_DIR/output.file"
  13. tss2 provision
  14. expect <<EOF
  15. # Try with wrong size value
  16. spawn tss2 getrandom --numBytes=a --data=$OUTPUT_FILE --force
  17. set ret [wait]
  18. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  19. Command has not failed as expected\n"
  20. exit 1
  21. }
  22. EOF
  23. expect <<EOF
  24. # Try with missing output
  25. spawn tss2 getrandom --numBytes=20
  26. set ret [wait]
  27. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  28. Command has not failed as expected\n"
  29. exit 1
  30. }
  31. EOF
  32. expect <<EOF
  33. # Try with missing numBytes
  34. spawn tss2 getrandom --data=$OUTPUT_FILE --force
  35. set ret [wait]
  36. if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
  37. Command has not failed as expected\n"
  38. exit 1
  39. }
  40. EOF
  41. tss2 getrandom --numBytes=4 --data=$OUTPUT_FILE --force
  42. tss2 getrandom --numBytes=4 --hex --data=$OUTPUT_FILE --force
  43. exit 0