esys-set-algorithm-set.int.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_SetAlgorithmSet.
  17. *
  18. *\b Note: platform authorization needed.
  19. *
  20. * Tested ESYS commands:
  21. * - Esys_SetAlgorithmSet() (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_set_algorithm_set(ESYS_CONTEXT * esys_context)
  30. {
  31. TSS2_RC r;
  32. int failure_return = EXIT_FAILURE;
  33. UINT32 algorithmSet = 0;
  34. r = Esys_SetAlgorithmSet(
  35. esys_context,
  36. ESYS_TR_RH_PLATFORM,
  37. ESYS_TR_PASSWORD,
  38. ESYS_TR_NONE,
  39. ESYS_TR_NONE,
  40. algorithmSet);
  41. if ((r == TPM2_RC_COMMAND_CODE) ||
  42. (r == (TPM2_RC_COMMAND_CODE | TSS2_RESMGR_RC_LAYER)) ||
  43. (r == (TPM2_RC_COMMAND_CODE | TSS2_RESMGR_TPM_RC_LAYER))) {
  44. LOG_WARNING("Command TPM2_SetAlgorithmSet not supported by TPM.");
  45. failure_return = EXIT_SKIP;
  46. goto error;
  47. }
  48. if (number_rc(r) == TPM2_RC_BAD_AUTH) {
  49. /* Platform authorization not possible test will be skipped */
  50. LOG_WARNING("Platform authorization not possible.");
  51. failure_return = EXIT_SKIP;
  52. }
  53. goto_if_error(r, "Error: SetAlgorithmSet", error);
  54. return EXIT_SUCCESS;
  55. error:
  56. return failure_return;
  57. }
  58. int
  59. test_invoke_esys(ESYS_CONTEXT * esys_context) {
  60. return test_esys_set_algorithm_set(esys_context);
  61. }