1 /********************************************************************************/
4 /* Written by Stefan Berger */
5 /* IBM Thomas J. Watson Research Center */
7 /* (c) Copyright IBM Corporation 2015. */
9 /* All rights reserved. */
11 /* Redistribution and use in source and binary forms, with or without */
12 /* modification, are permitted provided that the following conditions are */
15 /* Redistributions of source code must retain the above copyright notice, */
16 /* this list of conditions and the following disclaimer. */
18 /* Redistributions in binary form must reproduce the above copyright */
19 /* notice, this list of conditions and the following disclaimer in the */
20 /* documentation and/or other materials provided with the distribution. */
22 /* Neither the names of the IBM Corporation nor the names of its */
23 /* contributors may be used to endorse or promote products derived from */
24 /* this software without specific prior written permission. */
26 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
27 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
28 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
29 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
30 /* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
31 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
32 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
33 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
34 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
35 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
36 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
37 /********************************************************************************/
44 #include "tpm2/TpmTypes.h"
45 #include "tpm2/TpmBuildSwitches.h"
46 #include "tpm2/_TPM_Hash_Start_fp.h"
47 #include "tpm2/_TPM_Hash_Data_fp.h"
48 #include "tpm2/_TPM_Hash_End_fp.h"
49 #include "tpm2/TpmTcpProtocol.h"
50 #include "tpm2/Platform_fp.h"
51 #include "tpm2/Simulator_fp.h"
53 #define TPM_HAVE_TPM2_DECLARATIONS
54 #include "tpm_library_intern.h"
55 #include "tpm_error.h"
57 TPM_RESULT
TPM2_IO_TpmEstablished_Get(TPM_BOOL
*tpmEstablished
)
59 *tpmEstablished
= _rpc__Signal_GetTPMEstablished();
64 TPM_RESULT
TPM2_IO_TpmEstablished_Reset(void)
66 TPM_RESULT ret
= TPM_SUCCESS
;
67 struct libtpms_callbacks
*cbs
= TPMLIB_GetCallbacks();
68 TPM_MODIFIER_INDICATOR locality
= 0;
69 uint32_t tpm_number
= 0;
71 if (cbs
->tpm_io_getlocality
) {
72 cbs
->tpm_io_getlocality(&locality
, tpm_number
);
75 _plat__LocalitySet(locality
);
77 if (locality
== 3 || locality
== 4) {
78 _rpc__Signal_ResetTPMEstablished();
80 ret
= TPM_BAD_LOCALITY
;
86 TPM_RESULT
TPM2_IO_Hash_Start(void)
90 _rpc__Signal_SetTPMEstablished();
95 TPM_RESULT
TPM2_IO_Hash_Data(const unsigned char *data
,
98 _TPM_Hash_Data(data_length
, (unsigned char *)data
);
103 TPM_RESULT
TPM2_IO_Hash_End(void)