incrementalselftest.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # SPDX-License-Identifier: BSD-3-Clause
  2. source helpers.sh
  3. cleanup() {
  4. if [ "$1" != "no-shut-down" ]; then
  5. shut_down
  6. fi
  7. }
  8. trap cleanup EXIT
  9. start_up
  10. cleanup "no-shut-down"
  11. # Get the list of remaining algs to be tested
  12. temp=$(mktemp)
  13. tpm2 incrementalselftest > "${temp}"
  14. cat ${temp}
  15. alglist="$(yaml_get_kv "${temp}" "remaining" || true)"
  16. rm -f "${temp}"
  17. # If the list of remaining algs is not empty, we can test
  18. # the behaviour of tpm2 incrementalselftest and see
  19. # each alg become scheduled and tested. If there are
  20. # some leftovers, just print them
  21. if [ -n "${alglist}" ]; then
  22. for i in ${alglist}; do
  23. if ! tpm2 incrementalselftest "${i}" ; then
  24. echo "${i} failed to be tested."
  25. exit 1
  26. fi
  27. done
  28. localtmp=$(mktemp)
  29. tpm2 incrementalselftest > "${localtmp}"
  30. alglist="$(yaml_get_kv "${localtmp}" "remaining" || true)"
  31. rm -f "${localtmp}"
  32. if [ -n "${alglist}" ]; then
  33. echo "Algorithm suite remaning : ${alglist}"
  34. else
  35. true
  36. fi
  37. fi
  38. # Finally just verify that every algorithm are
  39. # effectively being already tested
  40. aesmodes="$(populate_algs "details['encrypting'] and details['symmetric']")"
  41. hashalgs="$(populate_algs "details['hash'] and not details['method'] \
  42. and not details['signing'] \
  43. and not details['symmetric'] \
  44. and alg is not None")"
  45. eccmethods="$(populate_algs "details['signing'] and not details['hash'] \
  46. and \"ec\" in alg")"
  47. rsamethods="$(populate_algs "details['signing'] and not details['hash'] \
  48. and \"rsa\" in alg")"
  49. # Check testing of AES modes
  50. tpm2 incrementalselftest ${aesmodes} | grep -q "complete"
  51. # Check testing of Hash algorithms
  52. tpm2 incrementalselftest ${hashalgs} | grep -q "complete"
  53. # Check testing of ECC methods
  54. tpm2 incrementalselftest ${eccmethods} | grep -q "complete"
  55. # Check testing of RSA methods
  56. tpm2 incrementalselftest ${rsamethods} | grep -q "complete"
  57. exit 0