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 
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10 
11 #include <stdlib.h>
12 
13 #include "tss2_esys.h"
14 
15 #include "esys_iutil.h"
16 #define LOGMODULE test
17 #include "util/log.h"
18 #include "util/aux_util.h"
19 
20 /** This test is intended to test the ESAPI get capability command.
21  *
22  * Tested ESAPI commands:
23  *  - Esys_GetCapability() (M)
24  *
25  * @param[in,out] esys_context The ESYS_CONTEXT.
26  * @retval EXIT_FAILURE
27  * @retval EXIT_SUCCESS
28  */
29 
30 int
test_esys_get_capability(ESYS_CONTEXT * esys_context)31 test_esys_get_capability(ESYS_CONTEXT * esys_context)
32 {
33     TSS2_RC r;
34     TPM2_CAP                       capability = TPM2_CAP_TPM_PROPERTIES;
35     UINT32                         property = TPM2_PT_LOCKOUT_COUNTER;
36     UINT32                         propertyCount = 1;
37     TPMS_CAPABILITY_DATA           *capabilityData;
38     TPMI_YES_NO                    moreData;
39 
40 
41     r = Esys_GetCapability(esys_context,
42                            ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE,
43                            capability, property, propertyCount,
44                            &moreData, &capabilityData);
45 
46     goto_if_error(r, "Error esys get capability", error);
47 
48     return EXIT_SUCCESS;
49 
50  error:
51     return EXIT_FAILURE;
52 }
53 
54 int
test_invoke_esapi(ESYS_CONTEXT * esys_context)55 test_invoke_esapi(ESYS_CONTEXT * esys_context) {
56     return test_esys_get_capability(esys_context);
57 }
58