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 <stdlib.h>
12
13 #include "tss2_sys.h"
14
15 #include <stdio.h>
16 #define LOGMODULE test
17 #include "util/log.h"
18 #include "test.h"
19
20 #define TSSWG_INTEROP 1
21 #define TSS_SAPI_FIRST_FAMILY 2
22 #define TSS_SAPI_FIRST_LEVEL 1
23 #define TSS_SAPI_FIRST_VERSION 108
24
25 /**
26 */
27 int
test_invoke(TSS2_SYS_CONTEXT * sapi_context)28 test_invoke (TSS2_SYS_CONTEXT *sapi_context)
29 {
30 TSS2_RC rc;
31 UINT32 contextSize;
32 TSS2_TCTI_CONTEXT *tcti_context = NULL;
33 TSS2_ABI_VERSION tstAbiVersion = { TSSWG_INTEROP, TSS_SAPI_FIRST_FAMILY, TSS_SAPI_FIRST_LEVEL, TSS_SAPI_FIRST_VERSION };
34
35 LOG_INFO( "ABI NEGOTIATION TESTS" );
36
37 /* Get the size needed for sapi context structure. */
38 contextSize = Tss2_Sys_GetContextSize( 0 );
39
40 rc = Tss2_Sys_GetTctiContext (sapi_context, &tcti_context);
41 if( rc != TSS2_RC_SUCCESS )
42 {
43 LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
44 exit(1);
45 }
46
47 /* Initialize the system context structure. */
48 tstAbiVersion.tssCreator = 0xF0000000;
49 rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion );
50 if( rc != TSS2_SYS_RC_ABI_MISMATCH )
51 {
52 LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
53 exit(1);
54 }
55
56 tstAbiVersion.tssCreator = TSSWG_INTEROP;
57 tstAbiVersion.tssFamily = 0xF0000000;
58 rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion );
59 if( rc != TSS2_SYS_RC_ABI_MISMATCH )
60 {
61 LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
62 exit(1);
63 }
64
65 tstAbiVersion.tssFamily = TSS_SAPI_FIRST_FAMILY;
66 tstAbiVersion.tssLevel = 0xF0000000;
67 rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion );
68 if( rc != TSS2_SYS_RC_ABI_MISMATCH )
69 {
70 LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
71 exit(1);
72 }
73
74 tstAbiVersion.tssLevel = TSS_SAPI_FIRST_LEVEL;
75 tstAbiVersion.tssVersion = 0xF0000000;
76 rc = Tss2_Sys_Initialize( sapi_context, contextSize, tcti_context, &tstAbiVersion );
77 if( rc != TSS2_SYS_RC_ABI_MISMATCH )
78 {
79 LOG_ERROR("ABIVersion FAILED! Response Code : %x", rc);
80 }
81
82
83 LOG_INFO("ABIVersion Test Passed!");
84 return 0;
85 }
86