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_fapi.h"
14
15 #define LOGMODULE test
16 #include "util/log.h"
17 #include "util/aux_util.h"
18
19 /** Test the FAPI functions for GetInfo.
20 *
21 * Tested FAPI commands:
22 * - Fapi_Provision()
23 * - Fapi_GetInfo()
24 * - Fapi_Delete()
25 *
26 * @param[in,out] context The FAPI_CONTEXT.
27 * @retval EXIT_FAILURE
28 * @retval EXIT_SUCCESS
29 */
30 int
test_fapi_info(FAPI_CONTEXT * context)31 test_fapi_info(FAPI_CONTEXT *context)
32 {
33
34 TSS2_RC r;
35 char *info = NULL;
36
37 r = Fapi_Provision(context, NULL, NULL, NULL);
38 goto_if_error(r, "Error Fapi_Provision", error);
39
40 r = Fapi_GetInfo(context, &info);
41 goto_if_error(r, "Error Fapi_Provision", error);
42
43 LOG_INFO("%s", info);
44
45 /* Cleanup */
46 r = Fapi_Delete(context, "/HS/SRK");
47 goto_if_error(r, "Error Fapi_Delete", error);
48
49 SAFE_FREE(info);
50 return EXIT_SUCCESS;
51
52 error:
53 Fapi_Delete(context, "/HS/SRK");
54 SAFE_FREE(info);
55 return EXIT_FAILURE;
56 }
57
58 int
test_invoke_fapi(FAPI_CONTEXT * fapi_context)59 test_invoke_fapi(FAPI_CONTEXT *fapi_context)
60 {
61 return test_fapi_info(fapi_context);
62 }
63