Coverage Report

Created: 2026-11-12 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libtpms/src/tpm_tpm2_tis.c
Line
Count
Source
1
/********************************************************************************/
2
/*                                                                              */
3
/*                              TPM TIS I/O         */
4
/*                           Written by Stefan Berger                           */
5
/*                     IBM Thomas J. Watson Research Center                     */
6
/*                                                                              */
7
/* (c) Copyright IBM Corporation 2015.            */
8
/*                    */
9
/* All rights reserved.               */
10
/*                    */
11
/* Redistribution and use in source and binary forms, with or without   */
12
/* modification, are permitted provided that the following conditions are */
13
/* met:                   */
14
/*                    */
15
/* Redistributions of source code must retain the above copyright notice, */
16
/* this list of conditions and the following disclaimer.      */
17
/*                    */
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.   */
21
/*                    */
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.     */
25
/*                    */
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
/********************************************************************************/
38
39
#include <config.h>
40
41
#include <stdint.h>
42
43
#include "Tpm.h"
44
#include "TpmTcpProtocol.h"
45
#include "Simulator_fp.h"
46
#include "prototypes/platform_public_interface.h"
47
48
#define TPM_HAVE_TPM2_DECLARATIONS
49
#include "tpm_library_intern.h"
50
#include "tpm_error.h"
51
52
TPM_RESULT TPM2_IO_TpmEstablished_Get(TPM_BOOL *tpmEstablished)
53
0
{
54
0
    *tpmEstablished = _rpc__Signal_GetTPMEstablished();
55
56
0
    return TPM_SUCCESS;
57
0
}
58
59
TPM_RESULT TPM2_IO_TpmEstablished_Reset(void)
60
0
{
61
0
    TPM_RESULT ret = TPM_SUCCESS;
62
0
    struct libtpms_callbacks *cbs = TPMLIB_GetCallbacks();
63
0
    TPM_MODIFIER_INDICATOR locality = 0;
64
0
    uint32_t tpm_number = 0;
65
66
0
    if (cbs->tpm_io_getlocality) {
67
0
        cbs->tpm_io_getlocality(&locality, tpm_number);
68
0
    }
69
70
0
    _plat__LocalitySet(locality);
71
72
0
    if (locality == 3 || locality == 4) {
73
0
        _rpc__Signal_ResetTPMEstablished();
74
0
    } else {
75
0
        ret = TPM_BAD_LOCALITY;
76
0
    }
77
78
0
    return ret;
79
0
}
80
81
TPM_RESULT TPM2_IO_Hash_Start(void)
82
0
{
83
0
    _TPM_Hash_Start();
84
85
0
    _rpc__Signal_SetTPMEstablished();
86
87
0
    return TPM_SUCCESS;
88
0
}
89
90
TPM_RESULT TPM2_IO_Hash_Data(const unsigned char *data,
91
                             uint32_t data_length)
92
0
{
93
0
    _TPM_Hash_Data(data_length, (unsigned char *)data);
94
95
0
    return TPM_SUCCESS;
96
0
}
97
98
TPM_RESULT TPM2_IO_Hash_End(void)
99
0
{
100
0
    _TPM_Hash_End();
101
102
0
    return TPM_SUCCESS;
103
0
}