sys-tpm-properties.int.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: BSD-2-Clause */
  2. /***********************************************************************
  3. * Copyright (c) 2017-2018, Intel Corporation
  4. *
  5. * All rights reserved.
  6. ***********************************************************************/
  7. #ifdef HAVE_CONFIG_H
  8. #include <config.h>
  9. #endif
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include "tss2_sys.h"
  13. #define LOGMODULE test
  14. #include "util/log.h"
  15. #include "test.h"
  16. int
  17. test_invoke (TSS2_SYS_CONTEXT *sys_context)
  18. {
  19. TSS2_RC rc;
  20. TPMS_CAPABILITY_DATA capability_data;
  21. LOG_INFO("Get TPM Properties Test started.");
  22. rc = Tss2_Sys_GetCapability(sys_context, 0, TPM2_CAP_TPM_PROPERTIES,
  23. TPM2_PT_MANUFACTURER, 1, 0, &capability_data, 0);
  24. if (rc != TSS2_RC_SUCCESS ||
  25. capability_data.data.tpmProperties.tpmProperty[0].property != TPM2_PT_MANUFACTURER) {
  26. LOG_ERROR("Get TPM Properties TPM2_PT_MANUFACTURER FAILED! Response Code : 0x%x", rc);
  27. exit(1);
  28. }
  29. LOG_INFO("TPM Manufacturer 0x%x", capability_data.data.tpmProperties.tpmProperty[0].value);
  30. rc = Tss2_Sys_GetCapability(sys_context, 0, TPM2_CAP_TPM_PROPERTIES,
  31. TPM2_PT_REVISION, 1, 0, &capability_data, 0);
  32. if (rc != TSS2_RC_SUCCESS ||
  33. capability_data.data.tpmProperties.tpmProperty[0].property != TPM2_PT_REVISION) {
  34. LOG_ERROR("Get TPM Properties TPM2_PT_REVISION FAILED! Response Code : 0x%x", rc);
  35. exit(1);
  36. }
  37. LOG_INFO("TPM revision 0x%X", capability_data.data.tpmProperties.tpmProperty[0].value);
  38. LOG_INFO("Get TPM Properties Test Passed!");
  39. return 0;
  40. }