esys-change-eps.int.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: BSD-2-Clause */
  2. /*******************************************************************************
  3. * Copyright 2017-2018, Fraunhofer SIT sponsored by Infineon Technologies AG
  4. * All rights reserved.
  5. *******************************************************************************/
  6. #ifdef HAVE_CONFIG_H
  7. #include <config.h>
  8. #endif
  9. #include <stdlib.h>
  10. #include "tss2_esys.h"
  11. #include "esys_iutil.h"
  12. #include "test-esys.h"
  13. #define LOGMODULE test
  14. #include "util/log.h"
  15. #include "util/aux_util.h"
  16. /** Test the ESYS function Esys_ChangeEPS.
  17. *
  18. *\b Note: platform authorization needed.
  19. *
  20. * Tested ESYS commands:
  21. * - Esys_ChangeEPS() (O)
  22. *
  23. * @param[in,out] esys_context The ESYS_CONTEXT.
  24. * @retval EXIT_FAILURE
  25. * @retval EXIT_SKIP
  26. * @retval EXIT_SUCCESS
  27. */
  28. int
  29. test_esys_change_eps(ESYS_CONTEXT * esys_context)
  30. {
  31. TSS2_RC r;
  32. ESYS_TR authHandle = ESYS_TR_RH_PLATFORM;
  33. r = Esys_ChangeEPS(
  34. esys_context,
  35. authHandle,
  36. ESYS_TR_PASSWORD,
  37. ESYS_TR_NONE,
  38. ESYS_TR_NONE);
  39. if ((r == TPM2_RC_COMMAND_CODE) ||
  40. (r == (TPM2_RC_COMMAND_CODE | TSS2_RESMGR_RC_LAYER)) ||
  41. (r == (TPM2_RC_COMMAND_CODE | TSS2_RESMGR_TPM_RC_LAYER))) {
  42. LOG_WARNING("Command TPM2_ChangeEPS not supported by TPM.");
  43. return EXIT_SKIP;
  44. goto error;
  45. }
  46. if (number_rc(r) == TPM2_RC_BAD_AUTH) {
  47. /* Platform authorization not possible test will be skipped */
  48. LOG_WARNING("Platform authorization not possible.");
  49. return EXIT_SKIP;
  50. }
  51. goto_if_error(r, "Error: ChangeEPS", error);
  52. return EXIT_SUCCESS;
  53. error:
  54. return EXIT_FAILURE;
  55. }
  56. int
  57. test_invoke_esys(ESYS_CONTEXT * esys_context) {
  58. return test_esys_change_eps(esys_context);
  59. }