Coverage Report

Created: 2025-08-26 06:23

/src/libtpms/src/tpm2/ManagementCommands.c
Line
Count
Source (jump to first uncovered line)
1
/********************************************************************************/
2
/*                    */
3
/*      Miscellaneous Management Functions        */
4
/*           Written by Ken Goldman       */
5
/*           IBM Thomas J. Watson Research Center     */
6
/*            $Id: ManagementCommands.c 1490 2019-07-26 21:13:22Z kgoldman $  */
7
/*                    */
8
/*  Licenses and Notices              */
9
/*                    */
10
/*  1. Copyright Licenses:              */
11
/*                    */
12
/*  - Trusted Computing Group (TCG) grants to the user of the source code in  */
13
/*    this specification (the "Source Code") a worldwide, irrevocable,    */
14
/*    nonexclusive, royalty free, copyright license to reproduce, create  */
15
/*    derivative works, distribute, display and perform the Source Code and */
16
/*    derivative works thereof, and to grant others the rights granted herein.  */
17
/*                    */
18
/*  - The TCG grants to the user of the other parts of the specification  */
19
/*    (other than the Source Code) the rights to reproduce, distribute,   */
20
/*    display, and perform the specification solely for the purpose of    */
21
/*    developing products based on such documents.        */
22
/*                    */
23
/*  2. Source Code Distribution Conditions:         */
24
/*                    */
25
/*  - Redistributions of Source Code must retain the above copyright licenses,  */
26
/*    this list of conditions and the following disclaimers.      */
27
/*                    */
28
/*  - Redistributions in binary form must reproduce the above copyright   */
29
/*    licenses, this list of conditions and the following disclaimers in the  */
30
/*    documentation and/or other materials provided with the distribution.  */
31
/*                    */
32
/*  3. Disclaimers:               */
33
/*                    */
34
/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
35
/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
36
/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
37
/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.   */
38
/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for    */
39
/*  information on specification licensing rights available through TCG   */
40
/*  membership agreements.              */
41
/*                    */
42
/*  - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED   */
43
/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR   */
44
/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR    */
45
/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY    */
46
/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.   */
47
/*                    */
48
/*  - Without limitation, TCG and its members and licensors disclaim all  */
49
/*    liability, including liability for infringement of any proprietary  */
50
/*    rights, relating to use of information in this specification and to the */
51
/*    implementation of this specification, and TCG disclaims all liability for */
52
/*    cost of procurement of substitute goods or services, lost profits, loss   */
53
/*    of use, loss of data or any incidental, consequential, direct, indirect,  */
54
/*    or special damages, whether under contract, tort, warranty or otherwise,  */
55
/*    arising in any way out of use or reliance upon this specification or any  */
56
/*    information herein.             */
57
/*                    */
58
/*  (c) Copyright IBM Corp. and others, 2016 - 2021       */
59
/*                    */
60
/********************************************************************************/
61
62
#include "Tpm.h"
63
#include "PP_Commands_fp.h"
64
#if CC_PP_Commands  // Conditional expansion of this file
65
TPM_RC
66
TPM2_PP_Commands(
67
     PP_Commands_In  *in             // IN: input parameter list
68
     )
69
0
{
70
0
    UINT32          i;
71
    // The command needs NV update.  Check if NV is available.
72
    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at
73
    // this point
74
0
    RETURN_IF_NV_IS_NOT_AVAILABLE;
75
    // Internal Data Update
76
    // Process set list
77
0
    for(i = 0; i < in->setList.count; i++)
78
  // If command is implemented, set it as PP required.  If the input
79
  // command is not a PP command, it will be ignored at
80
  // PhysicalPresenceCommandSet().
81
  // Note: PhysicalPresenceCommandSet() checks if the command is implemented.
82
0
  PhysicalPresenceCommandSet(in->setList.commandCodes[i]);
83
    // Process clear list
84
0
    for(i = 0; i < in->clearList.count; i++)
85
  // If command is implemented, clear it as PP required.  If the input
86
  // command is not a PP command, it will be ignored at
87
  // PhysicalPresenceCommandClear().  If the input command is
88
  // TPM2_PP_Commands, it will be ignored as well
89
0
  PhysicalPresenceCommandClear(in->clearList.commandCodes[i]);
90
    // Save the change of PP list
91
0
    NV_SYNC_PERSISTENT(ppList);
92
0
    return TPM_RC_SUCCESS;
93
0
}
94
#endif // CC_PP_Commands
95
#include "Tpm.h"
96
#include "SetAlgorithmSet_fp.h"
97
#if CC_SetAlgorithmSet  // Conditional expansion of this file
98
TPM_RC
99
TPM2_SetAlgorithmSet(
100
         SetAlgorithmSet_In  *in             // IN: input parameter list
101
         )
102
1
{
103
    // The command needs NV update.  Check if NV is available.
104
    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at
105
    // this point
106
1
    RETURN_IF_NV_IS_NOT_AVAILABLE;
107
    // Internal Data Update
108
1
    gp.algorithmSet = in->algorithmSet;
109
    // Write the algorithm set changes to NV
110
1
    NV_SYNC_PERSISTENT(algorithmSet);
111
1
    return TPM_RC_SUCCESS;
112
1
}
113
#endif // CC_SetAlgorithmSet