esys-get-capability.int.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #define LOGMODULE test
  13. #include "util/log.h"
  14. #include "util/aux_util.h"
  15. /** This test is intended to test the ESYS get capability command.
  16. *
  17. * Tested ESYS commands:
  18. * - Esys_GetCapability() (M)
  19. *
  20. * @param[in,out] esys_context The ESYS_CONTEXT.
  21. * @retval EXIT_FAILURE
  22. * @retval EXIT_SUCCESS
  23. */
  24. int
  25. test_esys_get_capability(ESYS_CONTEXT * esys_context)
  26. {
  27. TSS2_RC r;
  28. TPM2_CAP capability = TPM2_CAP_TPM_PROPERTIES;
  29. UINT32 property = TPM2_PT_LOCKOUT_COUNTER;
  30. UINT32 propertyCount = 1;
  31. TPMS_CAPABILITY_DATA *capabilityData;
  32. TPMI_YES_NO moreData;
  33. r = Esys_GetCapability(esys_context,
  34. ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE,
  35. capability, property, propertyCount,
  36. &moreData, &capabilityData);
  37. goto_if_error(r, "Error esys get capability", error);
  38. SAFE_FREE(capabilityData);
  39. return EXIT_SUCCESS;
  40. error:
  41. SAFE_FREE(capabilityData);
  42. return EXIT_FAILURE;
  43. }
  44. int
  45. test_invoke_esys(ESYS_CONTEXT * esys_context) {
  46. return test_esys_get_capability(esys_context);
  47. }