xref: /aosp_15_r20/external/tpm2-tss/test/integration/sapi-tpm-properties.int.c (revision 758e9fba6fc9adbf15340f70c73baee7b168b1c9)
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 
11 #include <stdio.h>
12 #include <stdlib.h>
13 
14 #include "tss2_sys.h"
15 
16 #define LOGMODULE test
17 #include "util/log.h"
18 #include "test.h"
19 
20 int
test_invoke(TSS2_SYS_CONTEXT * sapi_context)21 test_invoke (TSS2_SYS_CONTEXT *sapi_context)
22 {
23     TSS2_RC rc;
24     TPMS_CAPABILITY_DATA capability_data;
25 
26     LOG_INFO("Get TPM Properties Test started.");
27     rc = Tss2_Sys_GetCapability(sapi_context, 0, TPM2_CAP_TPM_PROPERTIES,
28                                 TPM2_PT_MANUFACTURER, 1, 0, &capability_data, 0);
29     if (rc != TSS2_RC_SUCCESS ||
30         capability_data.data.tpmProperties.tpmProperty[0].property != TPM2_PT_MANUFACTURER) {
31         LOG_ERROR("Get TPM Properties TPM2_PT_MANUFACTURER FAILED! Response Code : 0x%x", rc);
32         exit(1);
33     }
34     LOG_INFO("TPM Manufacturer 0x%x", capability_data.data.tpmProperties.tpmProperty[0].value);
35 
36     rc = Tss2_Sys_GetCapability(sapi_context, 0, TPM2_CAP_TPM_PROPERTIES,
37                                 TPM2_PT_REVISION, 1, 0, &capability_data, 0);
38     if (rc != TSS2_RC_SUCCESS ||
39         capability_data.data.tpmProperties.tpmProperty[0].property != TPM2_PT_REVISION) {
40         LOG_ERROR("Get TPM Properties TPM2_PT_REVISION FAILED! Response Code : 0x%x", rc);
41         exit(1);
42     }
43     LOG_INFO("TPM revision 0x%X", capability_data.data.tpmProperties.tpmProperty[0].value);
44 
45     LOG_INFO("Get TPM Properties Test Passed!");
46     return 0;
47 }
48